Yakisoba
10-24-2006, 06:01 AM
I'm working with a small application that runs multiple threads and potentially can get caught up in a very deep recursive process...
Everything works fine and, obviously, as the recursion gets deeper the execution time is increased...
each time the recursive method is called it sends output to a text area that can be saved at the users request.
Once the program fills the text area with approximately 212000 lines it crashes and gives me a
"java.lang.OutOfMemoryError: Java heap space" error...
Is there a way I can monitor the Heap space being used (in real time) and detect when it reaches a certain point and have things fail a little more gracefully?
Upon "googling" for a solution I came across this page (http://www.javaspecialists.co.za/archive/Issue092.html) which gives an example of a OutOfMemoryError Warning System. This sounds like exactly what I am looking for but I can not get it to work for me...it's not much of a tutorial.
Any suggestions/tutorials would be greatly appreciated.
Thanks,
Yak
Everything works fine and, obviously, as the recursion gets deeper the execution time is increased...
each time the recursive method is called it sends output to a text area that can be saved at the users request.
Once the program fills the text area with approximately 212000 lines it crashes and gives me a
"java.lang.OutOfMemoryError: Java heap space" error...
Is there a way I can monitor the Heap space being used (in real time) and detect when it reaches a certain point and have things fail a little more gracefully?
Upon "googling" for a solution I came across this page (http://www.javaspecialists.co.za/archive/Issue092.html) which gives an example of a OutOfMemoryError Warning System. This sounds like exactly what I am looking for but I can not get it to work for me...it's not much of a tutorial.
Any suggestions/tutorials would be greatly appreciated.
Thanks,
Yak