Java 8 Launch - MetaSpaces
-
Upload
haim-yadid -
Category
Technology
-
view
257 -
download
0
description
Transcript of Java 8 Launch - MetaSpaces
ilJUG Java 8 Launch Event #2 Metaspaces
!
Haim Yadid - Performize-IT
About Me: Haim Yadid
•21 Years of SW development experience •Performance Expert •Consulting R&D Groups •Training: Java Performance Optimization •Organizing : ILJUG
IL JUG
•Israeli Java User Group •Reborn at 1/14 •Meetup : http://www.meetup.com/IL-JUG •G+: https://plus.google.com/u/0/communities/110138558454900054301
•Twitter: @il_jug
© Copyright Performize-IT LTD.
Major Memory Regions
Monitoring the JVM
Young PermTenured Code Cache
Heap Permanent generation Code Cache Native Memory
Heap Non Heap
NativeNative
© Copyright Performize-IT LTD.
Monitoring Memory
Jconsole Memory tab Jconsole overview tab Mbeans java.lang/Memory
HeapMemoryUsage Operation : gc
Mbeans java.lang/MemoryPool Per memory pool usage
Jstat –gccapacity
Monitoring the JVM
© Copyright Performize-IT LTD.
Permanent Generation
Holds class metadata Holds interned strings Classes may get collected (unloaded) if JVM finds they are no longer needed
Monitoring the JVM
© Copyright Performize IT LTD.
Interning Strings
Strings are immutable If two strings are equal a same string object can be used. Automatic for constant strings Requires intervention in some cases
String a = “Hello world” String b = “Hello world” String c = a+b; String d = a+b; c!= d!!!!
Tuning Memory: Memory Areas
© Copyright Performize IT LTD.
Interning Strings (Cont)
String.intern() always will return the same object Use it when
The domain is relatively small Trade memory for speed interning strings takes time Stored in the PERMGEN Requires larger PERMGEN size
Tuning Memory: Memory Areas
© Copyright Performize IT LTD.
Out of memory Heap space
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space Solutions:
Increase heap memory Analyze stack trace where OOM occurred Analyze memory dump (next chapter)
Tuning Memory: OOM
© Copyright Performize IT LTD.
Permanent Generation
When memory is not an issue set -XX:MaxPermSize=<n> -XX:PermSize=<n>
Enable PermGen GC on CMS -XX:+CMSClassUnloadingEnabled -XX:+PermGenSweepingEnabled (not required for HotSpot Java 6 JVMs.).
© Copyright Performize IT LTD.Tuning Memory: Memory Areas
© Copyright Performize IT LTD.
Tuning Permanent Generation
Usually needed ! Required when:
Application codebase is large String intern is extensively used
Find smallest permgen that will not throw OOM errors. Cover all areas of the application Leave additional 10MB free
© Copyright Performize IT LTD.Tuning Memory: Memory Areas
© Copyright Performize IT LTD.
Meta spaces - In J8
Permanent generation is removed Part of the native memory Not continuous with the Heap (good for 32 bit JVMs) Better for GC performance
special process for metaspace Deallocate class concurrently and not in GC pause
© Copyright Performize IT LTD.Tuning Memory: Memory Areas
© Copyright Performize IT LTD.
Allocation in Metaspace
Multiple memory map / virtual alloc Allocate address space per class loader Virtual address space return when class loader released minimize fregmentation
© Copyright Performize IT LTD.Tuning Memory: Memory Areas
© Copyright Performize IT LTD.
Configuration
-XX:MaxMetaspaceSize={unlimited} By default
Limited by memory + swap space Address space 32 bit
© Copyright Performize IT LTD.Tuning Memory: Memory Areas
© Copyright Performize IT LTD.
More configuration
InitialBootClassLoaderMetaspaceSize 4194304 MaxMetaspaceExpansion 5451776 MaxMetaspaceFreeRatio 70 MaxMetaspaceSize 18446744073709547520 MetaspaceSize 21807104 MinMetaspaceExpansion 339968 MinMetaspaceFreeRatio 40 UseLargePagesInMetaspace
© Copyright Performize IT LTD.Tuning Memory: Memory Areas
© Copyright Performize IT LTD.
Monitoring
jmap -clstats <pid>
© Copyright Performize IT LTD.Tuning Memory: Memory Areas
© Copyright Performize IT LTD.
Monitoring
jstat -gc <pid> !!
S0C S1C S0U S1U EC EU OC OU MC MU CCSC CCSU …. 3584.0 3584.0 0.0 224.0 87040.0 45719.4 29184.0 21994.1 32768.0 31755.8 3840.0 3582.8 …
© Copyright Performize IT LTD.Tuning Memory: Memory Areas
© Copyright Performize IT LTD.
Monitoring
jstat -gc <pid> !!
S0C S1C S0U S1U EC EU OC OU MC MU CCSC CCSU …. 3584.0 3584.0 0.0 224.0 87040.0 45719.4 29184.0 21994.1 32768.0 31755.8 3840.0 3582.8 …
© Copyright Performize IT LTD.Tuning Memory: Memory Areas
Thanks + Q&A + Contact Me
© Copyright Performize-IT LTD.
http://il.linkedin.com/in/haimyadid
www.performize-it.com
blog.performize-it.com
https://github.com/lifey
@lifeyx