Reputation: 317
following problem:
This loading is the peak of the used heap in the picture below. After this, the heap size increases from 130 to 500 MB, although only 110 MB are needed.
Well ok, no problem, annoying, but ok. But if I now start a save process (which needs ~100 MB) the Java VM crashes with the java.lang.OutOfMemoryError: Java heap space exception.
If I started the application with 750 MB heap size, it works fine. You see the short peak and it works fine:
Now my question: Why the hell do I get an OutOfMemoryError with 550 MB Heap Size? The application only needs 400 MB (at the highest peak)!
I do not know how to fix that :(
Please help me!
Upvotes: 4
Views: 5106
Reputation: 533870
The data is sampled. Just before it failed it was using 400 MB, and then some time later it tried to use more memory e.g. 600 MB but this didn't show because by the time the next sample was taken the OOME had happened and you usage is now much lower.
In short, your program can use memory faster than you can see in the graphs.
Upvotes: 1
Reputation: 9216
If you load 100Mb file, it doesn't yet mean that structures, used for this file in memory occupy 100M. For instance, if you have String, you also have 4 byte overhead for its length.
Upvotes: 1