Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java memory leak, visualvm showing wrong data

I've a java application running, after few hours it fulfills memory. I've tried to detect memory leak with visualvm but it shows wrong data (have no idea how that can happen).

In the screenshot you can see task manager showing memory usage of 700Mb and visualvm showing 225...

Does anyone know whats going on here?

Regards

enter image description here

like image 479
vach Avatar asked Jan 27 '14 09:01

vach


1 Answers

Beware that your OS is only aware of the total amount of memory java has reserved over the time (and java will not return that amount of memory easily AFAIK). However java may not be using all that memory at a given moment, so you can see differences between those two numbers.

For example, if you launch your program like this

java -Xmx512m -Xms256m ...

Then your JVM will take 256 MB as soon as it starts (and the OS will tell you so, more or less). However, if you open your memory peek tool (be it visualvm, jconsole, etc.), it may show that you are using less than that (it is just you have not needed to use the whole of your reserved heap).

like image 61
Jorge_B Avatar answered Oct 22 '22 13:10

Jorge_B