DEV Community

Discussion on: JVM memory leak, where to begin?

Collapse
 
jouo profile image
Jashua

No I actually didn't, would that be the problem?

I removed them because I wanted to see if the little app was stable, then I came across said memory leak

Collapse
 
josephtaylor profile image
J. Taylor O'Connor

I would try setting a max heap and see how that affects it. I can’t remember exactly what the calculation is but the JVM sets its default memory settings based on the overall system memory. If it’s assuming that it has a lot of memory available to it, it may allow the heap to grow without garbage collecting it. So, could be if you constrain the heap some more, the JVM will perform more garbage collection and keep the overall usage lower.

But, like other people are saying, your best window into what’s going on memory-wise is to take heap dumps and analyze them with a memory analyzer (MAT is a good free one that does leak suspect reports).

Thread Thread
 
smuschel profile image
smuschel

I think this would be your best option. Restrict max heap size an check if your app runs into an OutOfMemoryError. If that happens, use one of the mentioned tools to analyse your heap (take snapshots of your heap at different points in time, see what objects might accumulate).
But first, I'd also recommend to verify there's a memory issue

Thread Thread
 
jouo profile image
Jashua

I did it yesterday, and ran into a memory error (not sure which), logs said the JVM killed the child or something... I should've saved that log I'm sorry

But I do am working on it, already taking a course on JVM memory :)