Reputation: 1739
I'm trying to understand the total memory use of a JVM and a potential non-heap memory leak.
Process takes 1.9 GB on a AWS EC2 VM with just 1 GB. We have the JVM max heap memory limited to 512 MB.
CompressedClassSpaceSize = 1073741824 (1024.0MB)
We aren't using that many .jar libraries to make up 1 GB, I don't think.
Is there any way we can get a better breakdown of this? On the currently running JVM? Or re-starting it with some option to track this?
There is one thing which we do uniquely in our system: we load a great many resources from the classpath using the ClassLoader#getResource... and I wonder if that is causing the growth?
Details:
$ jcmd 94084 GC.heap_info
94084:
def new generation total 23552K, used 19966K [0x0000000812000000, 0x0000000813980000, 0x000000081caa0000)
eden space 20992K, 88% used [0x0000000812000000, 0x000000081323c850, 0x0000000813480000)
from space 2560K, 50% used [0x0000000813700000, 0x0000000813843090, 0x0000000813980000)
to space 2560K, 0% used [0x0000000813480000, 0x0000000813480000, 0x0000000813700000)
tenured generation total 52064K, used 31236K [0x000000081caa0000, 0x000000081fd78000, 0x0000000832000000)
the space 52064K, 59% used [0x000000081caa0000, 0x000000081e9213c8, 0x000000081e921400, 0x000000081fd78000)
Metaspace used 38523K, capacity 38938K, committed 39296K, reserved 1085440K
class space used 4029K, capacity 4147K, committed 4224K, reserved 1048576K
$ jmap -heap 94084
Attaching to process ID 94084, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.265-b01
using thread-local object allocation.
Mark Sweep Compact GC
Heap Configuration:
MinHeapFreeRatio = 40
MaxHeapFreeRatio = 70
MaxHeapSize = 536870912 (512.0MB)
NewSize = 5570560 (5.3125MB)
MaxNewSize = 178913280 (170.625MB)
OldSize = 11206656 (10.6875MB)
NewRatio = 2
SurvivorRatio = 8
MetaspaceSize = 21807104 (20.796875MB)
CompressedClassSpaceSize = 1073741824 (1024.0MB)
MaxMetaspaceSize = 17592186044415 MB
G1HeapRegionSize = 0 (0.0MB)
Upvotes: 1
Views: 1208
Reputation: 2676
1Gb is the default (max and reserved) size for “Compressed Class Metadata Space” a.k.a. CCMS. This is a new feature JVM8+. That doesn't mean all that space is in use, but JVM reserves that space just in case.
I am also deep-diving into non-heap JVM memory usage.
In my experience, the more common problem is "Metaspace". Metaspace is unbounded and it grows much faster and higher than CCMS ... so I would suggest you start by setting a limit to the metaspace using
"-XX:MaxMetaspaceSize=128m"
NOTE 128m is a value that might or might not fit your needs.
Anyway there are also flags to limit the CCMS size, and you can also completely disable that feature in exchange for more heap usage.
Upvotes: 1