Java 8 Launch - MetaSpaces

1,855 views

Published on

A short talk about metaspaces.

Published in: Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,855
On SlideShare
0
From Embeds
0
Number of Embeds
39
Actions
Shares
0
Downloads
32
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Java 8 Launch - MetaSpaces

  1. 1. ilJUG  Java  8  Launch  Event  #2   Metaspaces                                       ! Haim Yadid - Performize-IT
  2. 2. About  Me:  Haim  Yadid •21 Years of SW development experience •Performance Expert •Consulting R&D Groups •Training: Java Performance Optimization •Organizing : ILJUG
  3. 3. 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
  4. 4. © 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
  5. 5. © 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
  6. 6. © 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
  7. 7. © 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
  8. 8. © 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
  9. 9. © 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
  10. 10. © 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
  11. 11. © 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
  12. 12. © 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
  13. 13. © 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
  14. 14. © 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
  15. 15. © 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
  16. 16. © Copyright Performize IT LTD. Monitoring jmap -clstats <pid> © Copyright Performize IT LTD. Tuning Memory: Memory Areas
  17. 17. © 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
  18. 18. © 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
  19. 19. Thanks + Q&A + Contact Me © Copyright Performize-IT LTD. http://il.linkedin.com/in/haimyadid lifey@performize-it.com www.performize-it.com blog.performize-it.com https://github.com/lifey @lifeyx

×