Question:
java.lang.OutOfMemoryError....?
sumantbhardvaj
2006-06-22 11:04:58 UTC
I am solving a graph problem in which i am traversing the graph through DFS to find the shortest distance ....

but i am getting the java.lang.OutOfMemoryError.... error....
Can anybody suggest the solution...
Three answers:
cantankerous_bunch
2006-06-22 11:34:40 UTC
java.lang.OutOfMemoryError probably means that you have a stack overflow problem. Did you write the program yourself? There is a java disassembler that you can download and try to see where the out of memory error happened otherwise you're stuck with it and you need to tell the person who wrote the program to fix it.
Mahesh Ramichetty
2006-06-23 00:19:12 UTC
This error mainly occurs because of the lack of the required memory heap for java this can be set from the command line -javaXmx for the maximium memeory.If this is increased then the problem will be solved. The current memory settings can be retrived using the API that is defined in the java.lang in the system class.



System.totalmemory();



System.freememory();
CByrd17
2006-06-22 11:14:49 UTC
Give the java compiler more memory to work with via the -Xmx option.



so you would use:



java -Xmx[some amount of memory here] [all your other options and executable here]



This is how to pick the right number:



-Xmxn

Specify the maximum size, in bytes, of the memory allocation pool. This value must a multiple of 1024 greater than 2MB. Append the letter k or K to indicate kilobytes, or m or M to indicate megabytes. The default value is 64MB. Examples:



-Xmx83886080

-Xmx81920k

-Xmx80m


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...