Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does JVM store memory in system ? If so, how to clear it?

I am running an application using NetBeans and in the project properties I have set the Max JVM heap space to 1 GiB.

But still, the application crashes with Out of Memory.

Does the JVM have memory stored in system? If so how to clear that memory?

like image 556
Nigel Thomas Avatar asked Dec 03 '22 00:12

Nigel Thomas


1 Answers

You'll want to analyse your code with a profiler - Netbeans has a good one. This will show you where the memory is tied up in your application, and should give you an idea as to where the problem lies.

The JVM will garbage collect objects as much as it can before it runs out of memory, so chances are you're holding onto references long after you no longer need them. Either that, or your application is genuinely one that requires a lot of memory - but I'd say it's far more likely to be a bug in your code, especially if the issue only crops up after running the application for a long period of time.

like image 186
Michael Berry Avatar answered Jan 12 '23 00:01

Michael Berry