Monday, July 16, 2007

How to resolve StackOverflowException in Java?

Well, not only when you use deep recursion that you encounter a StackOverflowException but also when you serialize objects you might see this exception.
Well you can always avoid this error by setting a VM option to java, either from eclipse or when you run it from command line, as an argument.
If it is in Eclipse, go to the Run dialog of the current Java program that you wish to run and go to the second tab (arguments I guess) and then in the VM Options you can set "-Xss1024K" which means that any thread that runs on Java VM will be allotted a Stack size of 1 MB which is quite enough for most of the cases.
If you wish to serialize data that has a lot of interlinked references then you might want to keep it something really high, just to be on safer side.
Interesting stuff is going on in the DBMS class at my university and we are learning really good stuff especially the performance oriented nature of DB algorithms! I enjoy the programming assignments, its fun to learn and code!

No comments: