Allocated memory vs. used memory

Questions about YourKit Java Profiler
Post Reply
runestilling
Posts: 3
Joined: Tue May 23, 2017 8:06 pm

Allocated memory vs. used memory

Post by runestilling »

Hi forum

I'm using YourKit to analyze a Tomcat Web application that seems to leak memory over time. But I'm not quite sure weather it's a leak or something else.

Memory shown for the process in the Windows Task Manager keeps growing. Looking at the process in YourKit tells a different story. In YourKit "all pools" also keeps growing but the rest om the different types seem constant (after GC). Also if make two memory snapshots they show no leaked objects.

Image

Thx,
Rune
runestilling
Posts: 3
Joined: Tue May 23, 2017 8:06 pm

Re: Allocated memory vs. used memory

Post by runestilling »

PS. For some reason the entire image doesn't show. Here's a link: http://rdfined.fastmail.fm/diverse/yourkit.png

PPS. I guess some of the answer lies in this post's reply:

viewtopic.php?f=3&t=3903
https://stackoverflow.com/questions/126 ... ol-divided

But even after many hours of idling the allocated memory isn't released:

http://rdfined.fastmail.fm/diverse/yourkit2.png
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Re: Allocated memory vs. used memory

Post by Anton Katilin »

Hello Rune

If you don't see any leaked objects between snapshots then you don't have any Java-side leaks, i.e. leaks in the Java heap.

However, a JVM process uses memory outside the Java heap too, for its internal structures. Perhaps this is how Java manages its memory allocation.

Is the observed memory growth infinite? For how long does the JVM process run?

Also, a leak may be caused by a native library allocating memory outside the heap. Do you know whether your application uses any?

Please also note that you monitor physical memory in Windows Task Manager. Switch to "Details" tab and make "Commit size" column which corresponds to virtual memory visible (right click the table title and select columns). Do you see that virtual memory grows as well?

Best regards,
Anton
runestilling
Posts: 3
Joined: Tue May 23, 2017 8:06 pm

Re: Allocated memory vs. used memory

Post by runestilling »

Hi Anton

Thank you for the reply. As far as I can tell from the yourkit memory graphs the both heap and non heap memory usage is constant:

http://rdfined.fastmail.fm/diverse/YourKit3.png
http://rdfined.fastmail.fm/diverse/YourKit4.png

But the numbers don't add up. The task manager still shows a higher memory usage (and growing).

My application shouldn't use any native libraries as far as I know (it's a web application running in a Tomcat 8.5 container).

The memory continues to grow.

/Rune
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Re: Allocated memory vs. used memory

Post by Anton Katilin »

Hi Rune

Task Manager shows total process memory usage. Java heap and non-heap are only part of it.
If the process memory grows but heaps don't, something happens outside the heaps. This may be JVMs memory usage, native library memory usage or even agent's memory usage.

Is the observed memory growth infinite? For how long does the JVM process run?

Anyway, could you please provide:
1. The profiler agent log file ~/.yjp/log/<session name>-<pid>.log
2. A performance snapshot of the application (.snapshot file).

You may zip them and send attached to [email protected]

Best regards,
Anton
Post Reply