Answer the question
In order to leave comments, you need to log in
Memory issues in Java?
It all started with the fact that the program began to crash when allocating memory, so I began to understand and added logging to the code.
rows and cols are 84 each.
writeLog("total " + Runtime.getRuntime().totalMemory() + " max " + Runtime.getRuntime().maxMemory() + " free " + Runtime.getRuntime().freeMemory());<br/>
<br/>
costMatrix = new byte[rows][cols][rows][cols];<br/>
writeLog("costMatrix allocated");<br/>
<br/>
writeLog("total " + Runtime.getRuntime().totalMemory() + " max " + Runtime.getRuntime().maxMemory() + " free " + Runtime.getRuntime().freeMemory());<br/>
<br/>
directionMatrix = new Aim[rows][cols][rows][cols];<br/>
writeLog("directionMatrix allocated");<br/>
<br/>
Answer the question
In order to leave comments, you need to log in
There is such a jvisualvm tool, it lies in $java_home$/bin.
Allows you to monitor exactly how memory is allocated. There is a detailed instruction for it on the oracle website, googled for visualvm.
1. What is the Aim class? If each instance takes up more than ~40 bytes, it's not surprising that an 84^4 array won't fit in 2 GB.
2. What exception did you try to catch? OutOfMemoryException (which happens for various reasons ) is not a descendant of java.lang.Exception.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question