I. Have. A memory leak


The title is probably the worst sentence I’ve ever known. Comming from C++ this really made me cry.
So. I’ve analyzed, checked that all streams are being closed and so on. Didn’t help.

I know my application will use a lot of memory. For reviewing some test results, it’s necessary to load ~150mb data, and create charts. Though this memory is
released again, and I can not figure out why. As the user leaves or choses a new test, the variables containing the data is overwritten, as well as the charts-layout is being cleared.

Is there something I don’t know?

I’ve tried calling the GC explicitly. Multiple. Times. I’ve tried giving it 12 hours. Nothing - this memory is not released.
My worst though is that each view is somehow “saved” - but that might just be a bad thought. But I really do not have any idea how to fix this.

I know the memoryleak happens whenever I
a) Load data to create a list of charts and a tabsheet of infos.
b) Create a report for this data.

Though, when the server hits 130mb free RAM, it doesn’t go lower. Somehow som aggressive GC happens (or something). Though at some point, the server will crash, that I’ve seen.

Is there anyway I can make sure, that these views are trashed, and do not consume memory? My server only has 4gb og memory, not much for such an application, but still - I really want a stable solution! :slight_smile:

Thank you - and have a great day! :slight_smile:

Best regards
A sad developer
Aka Benjamin

Very hard to say what is the reason for memory leak. Calling gc doesn’t help is there is nothing to carbage collect.
Does this happen with single session, whenever in this session the user loads the 150mb data?
Have you tried tools e.g. http://visualvm.java.net/ to find out the reason for memory leak?

You still have some “hard” reference to your old views somewhere. Try using VisualVM to find them or post some relevant code, maybe we are able to spot the problem.