Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How far does the new metaspace go and when will it stop

Tags:

java

java-8

With Java 8 removing PermGen, we can no longer use the JVM arguments to change it or limit it.

But if I have a memory leak in my app, I want to know about it. I do not want the JVM to allocate gigabytes of memory.

So my question is: how far will it go, when will it stop, and can I limit it from the OS (using ulimit)?

like image 562
David Limkys Avatar asked Sep 09 '14 21:09

David Limkys


People also ask

What is the difference between PermGen and Metaspace?

PermGen always has a fixed maximum size. Metaspace by default auto increases its size depending on the underlying OS.

What is Metaspace size?

The default size of -XX:MetaspaceSize is platform-dependent and ranges from 12 MB to about 20 MB. Information about the space used for metadata is included in a printout of the heap.

What is Metaspace used for?

Metaspace is a native memory region that stores metadata for classes. As a class is loaded by the JVM, its metadata (i.e. its runtime representation in the JVM) is allocated into the Metaspace. The Metaspace occupancy grows as more and more classes are loaded.

Is Metaspace part of heap?

The Metaspace takes up a significant portion of the JVM's Non-Heap memory. Its main purpose is to store class metadata — the internal runtime representation of Java classes. By default, the metaspace is comprised of two parts — the Class Space and the Non-Class Space.


1 Answers

Yes, by default metaspace is unlimited. Not to worry: you can still set an upper limit on the amount of metaspace available to the JVM. -XX:MaxMetaSpaceSize to the rescue.

http://java.dzone.com/articles/java-8-permgen-metaspace

like image 175
Matt Ball Avatar answered Nov 02 '22 04:11

Matt Ball