Java Stack Error
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring
How To Solve Stack Overflow Error In Java
developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question java increase stack size x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them;
How To Resolve Stack Overflow Error In Java
it only takes a minute: Sign up What is a StackOverflowError? up vote 221 down vote favorite 74 What is a StackOverflowError, what causes it, and how should I deal with them? java exception-handling stack-overflow share|improve this question edited Jun java stack overflow exception 19 '15 at 4:55 asked Oct 18 '08 at 8:13 Ziggy 7,384165475 add a comment| 11 Answers 11 active oldest votes up vote 230 down vote accepted Parameters and local variables are allocated on the stack (with reference types the object lives on the heap and a variable references that object). The stack typically lives at the upper end of your address space and as it is used up it heads towards the bottom of the address space (i.e. fix stack overflow error towards zero). Your process also has a heap, which lives at the bottom end of your process. As you allocate memory this heap can grow towards the upper end of your address space. As you can see, there is the potential for the heap to "collide" with the stack (a bit like tectonic plates!!!). The common cause for a stack overflow is a bad recursive call. Typically this is caused when your recursive functions doesn't have the correct termination condition, so it ends up calling itself forever. However, with GUI programming it's possible to generate indirect recursion. For example, your app may be handling paint messages and whilst processing them it may call a function that causes the system to send another paint message. Here you've not explicitly called yourself, but the OS/VM has done it for you. To deal with them you'll need to examine your code. If you've got functions that call themselves then check that you've got a terminating condition. If you have then check than when calling the function you have at least modified one of the arguments, otherwise there'll be no visible change for the recursively called function and the terminating condition is useless. If you've got no obvious recursive functions then check to see if you're calling any library functions that indirectly will cause your function to be called (like the implicit case above). share|improve this answer edited Jul 22 '14
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings
Stackoverflowerror Java Recursion
and policies of this site About Us Learn more about Stack Overflow stack overflow error in android the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation
Stack Overflow In Java With Example
Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it http://stackoverflow.com/questions/214741/what-is-a-stackoverflowerror only takes a minute: Sign up What actually causes a Stack Overflow error? [duplicate] up vote 204 down vote favorite 37 This question already has an answer here: What is a StackOverflowError? 11 answers I've looked everywhere and can't find a solid answer. According to the documentation, Java throws a java.lang.StackOverflowError error under the following circumstance: Thrown when a stack overflow http://stackoverflow.com/questions/22182669/what-actually-causes-a-stack-overflow-error occurs because an application recurses too deeply. But this raises two questions: Aren't there other ways for a stack overflow to occur, not only through recursion? Does the StackOverflowError happen before the JVM actually overflows the stack or after? To elaborate on the second question: When Java throws the StackOverflowError, can you safely assume that the stack did not write into the heap? If you shrink the size of the stack or heap in a try/catch on a function that throws a stack overflow, can you continue working? Is this documented anywhere? Answers I am not looking for: A StackOverflow happens because of bad recursion. A StackOverflow happens when the heap meets the stack. java jvm stack-overflow share|improve this question edited Mar 4 '14 at 21:54 hichris123 6,551113257 asked Mar 4 '14 at 20:46 retrohacker 1,66231025 marked as duplicate by Jarrod Robersonjava Users with the java badge can single-handedly close java questions as duplicates and reopen them as needed. Dec 28 '15 at 21:24 This question has been asked before and already has an answer. If those answers
and DropEventsExpandableListViewGridViewHorizontalScrollViewImageButtonImageViewLinearLayoutListViewNotificationsPasswordProgressBarProgressDialogRadioButtonRadioGroupRatingBarRelativeLayoutScrollViewSelectorSettingsSpinnerSurfaceViewTextBoxTimePickerToastToggleButtonWebViewviewMenuOnClickListenerViewPagerwidgetAutoCompleteTextViewEditTextFrameLayoutSeekBarSlidingDrawerStackViewTextViewViewFlipperxmlgamescanvasmain loopOpenGL ESCore JavaanimationapacheANTcommonsbeanutilsconvertersArrayConvertercliBasicParsercodecbinaryBase64Base64OutputStreamcsvdbcpBasicDatasourcePoolingConnectioniocomparatorCompositeFileComparatorDirectoryFileComparatorLastModifiedFileComparatorNameFileComparatorPathFileComparatorFilenameUtilsFileUtilsIOUtilsmonitorFileAlterationMonitorlang3CharUtilsClassPathUtilsmathFractionNumberUtilsStringUtilsloggingLogfactorynetCookieStoreFTPClientURLClassLoaderURLConnectionluceneappletaspectjbeanscajoCharacterclassComperablecryptoDesign PatternsdecoratorstrategyGenericsGradlegsonGsonBuilderstreamJsonReaderJsonWriterioBufferedInputStreamBufferedOutputStreamBufferedReaderBufferedWriterByteArrayInputStreamByteArrayOutputStreamConsoleDataInputStreamDataOutputStreamExternalizableFileFileDescriptorFileInputStreamFilenameFilterFileOutputStreamFileReaderFileWriterInputStreamInputStreamReaderIOExceptionObjectInputStreamObjectOutputStreamOutputStreamPrintWriterRandomAccessFileSerializableStreamTokenizerStringReaderStringWriterjsonJacksonJSON.SimplejunitlangmanagementNumberFormatExceptionProcessBuilderReferenceQueueRunnableRuntimeStringStringBufferStringBuilderSystemmathMockitonetAuthenticatorConnectExceptionCookieManagerCookieStoreDatagramPacketHttpCookieInetAddressJarURLConnectionMalformedURLExceptionMulticastSocketNetworkInterfaceServerSocketSocketSocketExceptionSocketTimeoutExceptionUnknownHostExceptionURISyntaxExceptionURLURLClassLoaderURLConnectionURLDecoderURLEncodernioBufferByteBufferchannelsAsynchronousChannelGroupAsynchronousFileChannelAsynchronousSocketChannelCompletionHandlerFileLockScatteringByteChannelSelectorspiSelectorProviderChar
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Programmers Questions Tags Users Badges Unanswered Ask Question _ Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer The best answers are voted up and rise to the top Is it *ever* okay to catch StackOverflowError in Java? up vote 26 down vote favorite 1 I used to think that it's not, but yesterday I had to do it. It's an application that uses Akka (an actor system implementation for the JVM) to process asynchronous jobs. One of the actors performs some PDF manipulation, and because the library is buggy, it dies with a StackOverflowError every now and then. The second aspect is that Akka is configured to shutdown its whole actor system if any JVM fatal error (e.g. StackOverflowError) is caught. The third aspect is that this actor system is embedded inside a web app (for WTF-ish, legacy, reasons), so when the actor system is shut down, the web app is not. The net effect is that on a StackOverflowError our job processing application becomes just an empty web app. As a quick fix I had to catch the StackOverflowError being thrown, so that the thread pool of the actor system isn't torn down. This lead me to think that maybe it's sometimes okay to catch such errors especially in contexts like this? When there's a thread pool processing arbitrary tasks? Unlike an OutOfMemoryError I can't imagine how a StackOverflowError can leave an application in an inconsistent state. The stack is cleared after such an error, so computation can go on normally. But maybe I'm missing something important. Also, let it be noted that I'm all for fixing the error in the first place (as a matter of fact I have already fixed an SOE in this same app a few days ago), but I really don't know when this kind of situation might arise. Why would it be better to restart the JVM process instead of catching the StackOverflowError, mark that job as failed, and continue with my business? Is there any compelling reason to never catch SOEs? Except "best practices", which is a vague term that tells me nothing. java jvm stackoverflow share|improve this question edited Aug 22 '13