Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Interned strings not in permgen?

I've run the jmap -heap command on our running Java application and here's what I got:

C:\Program Files\Java\jdk1.7.0_05\bin>jmap -heap 2384 Attaching to process ID 2384, please wait... Debugger attached successfully. Server compiler detected.
JVM version is 23.1-b03

using parallel threads in the new generation.
using thread-local object allocation.
Concurrent Mark-Sweep GC

Heap Configuration:
MinHeapFreeRatio = 40
MaxHeapFreeRatio = 70
MaxHeapSize = 1073741824 (1024.0MB)
NewSize = 1310720 (1.25MB)
MaxNewSize = 17592186044415 MB
OldSize = 5439488 (5.1875MB)
NewRatio = 2
SurvivorRatio = 8
PermSize = 134217728 (128.0MB)
MaxPermSize = 201326592 (192.0MB)
G1HeapRegionSize = 0 (0.0MB)

Heap Usage:
New Generation (Eden + 1 Survivor Space):
capacity = 228261888 (217.6875MB)
used = 203794000 (194.3531036376953MB)
free = 24467888 (23.334396362304688MB)
89.28078260703775% used
Eden Space:
capacity = 202964992 (193.5625MB)
used = 198399360 (189.2083740234375MB)
free = 4565632 (4.3541259765625MB)
97.75053226913141% used
From Space:
capacity = 25296896 (24.125MB)
used = 5394640 (5.1447296142578125MB)
free = 19902256 (18.980270385742188MB)
21.325304100550518% used
To Space:
capacity = 25296896 (24.125MB)
used = 0 (0.0MB)
free = 25296896 (24.125MB)
0.0% used
concurrent mark-sweep generation:
capacity = 506445824 (482.984375MB)
used = 159479408 (152.09141540527344MB)
free = 346966416 (330.89295959472656MB)
31.489924576809226% used
Perm Generation:
capacity = 134217728 (128.0MB)
used = 72157448 (68.81470489501953MB)
free = 62060280 (59.18529510498047MB)
53.76148819923401% used

96874 interned Strings occupying 89695496 bytes.

So it seems like there are approximately 89mb of interned strings in 68mb of Permgen. Are there interned strings that are not stored in the Permgen?

like image 227
Vic Avatar asked Apr 30 '13 10:04

Vic


People also ask

Where is interned string stored?

Intern strings are stored in a string pool in the JVM memory. JVM Memory has the following regions: Heap region (i.e. Young & Old generation) Metaspace.

Why did the string pool move from PermGen to the normal heap area?

Why did the String pool move from PermGen to normal heap area? PermGen space is limited space, the default size is just 64 MB. And it was a problem of creating and storing too many string objects in PermGen space. That's why the String pool is moved to a larger heap area.

What is stored in PermGen space?

The PermGen area of the Java heap is used to store metadata such as class declarations, methods and object arrays. Therefore, the PermGen size requirements depend on the number of classes and methods as well as their size. Java memory is separated into different regions - Young, Tenured and PermGen.

Why is there no PermGen space in Java 8?

PermGen space is replaced by MetaSpace in Java 8. The PermSize and MaxPermSize JVM arguments are ignored and a warning is issued if present at start-up. Most allocations for the class metadata are now allocated out of native memory. * The classes that were used to describe class metadata have been removed.


1 Answers

From Java 7 release notes:

In JDK 7, interned strings are no longer allocated in the permanent generation of the Java heap, but are instead allocated in the main part of the Java heap (known as the young and old generations), along with the other objects created by the application. This change will result in more data residing in the main Java heap, and less data in the permanent generation, and thus may require heap sizes to be adjusted. Most applications will see only relatively small differences in heap usage due to this change, but larger applications that load many classes or make heavy use of the String.intern() method will see more significant differences.

like image 65
dcernahoschi Avatar answered Oct 09 '22 04:10

dcernahoschi