SlideShare a Scribd company logo
1 of 33
Download to read offline
Chris Bailey – IBM Java Service Architect
9th September 2012




From Java Code to Java Heap
Understanding the Memory Usage of Your Application




                                                     © 2012 IBM Corporation
Important Disclaimers



THE INFORMATION CONTAINED IN THIS PRESENTATION IS PROVIDED FOR INFORMATIONAL PURPOSES
ONLY.

WHILST EFFORTS WERE MADE TO VERIFY THE COMPLETENESS AND ACCURACY OF THE INFORMATION
CONTAINED IN THIS PRESENTATION, IT IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED.

ALL PERFORMANCE DATA INCLUDED IN THIS PRESENTATION HAVE BEEN GATHERED IN A CONTROLLED
ENVIRONMENT. YOUR OWN TEST RESULTS MAY VARY BASED ON HARDWARE, SOFTWARE OR
INFRASTRUCTURE DIFFERENCES.

ALL DATA INCLUDED IN THIS PRESENTATION ARE MEANT TO BE USED ONLY AS A GUIDE.

IN ADDITION, THE INFORMATION CONTAINED IN THIS PRESENTATION IS BASED ON IBM’S CURRENT
PRODUCT PLANS AND STRATEGY, WHICH ARE SUBJECT TO CHANGE BY IBM, WITHOUT NOTICE.

IBM AND ITS AFFILIATED COMPANIES SHALL NOT BE RESPONSIBLE FOR ANY DAMAGES ARISING OUT OF
THE USE OF, OR OTHERWISE RELATED TO, THIS PRESENTATION OR ANY OTHER DOCUMENTATION.

NOTHING CONTAINED IN THIS PRESENTATION IS INTENDED TO, OR SHALL HAVE THE EFFECT OF:

- CREATING ANY WARRANT OR REPRESENTATION FROM IBM, ITS AFFILIATED COMPANIES OR ITS OR
THEIR SUPPLIERS AND/OR LICENSORS



2                      From Java Code to Java Heap: Understanding the Memory Usage of Your Application   © 2012 IBM Corporation
Introduction to the speaker



■   12 years experience developing and deploying Java SDKs




■   Recent work focus:
     – Java usability and quality
     – Debugging tools and capabilities
     – Requirements gathering
     – Highly resilient and scalable deployments




■   My contact information:
     – baileyc@uk.ibm.com
     – http://www.linkedin.com/profile/view?id=3100666



3                         From Java Code to Java Heap: Understanding the Memory Usage of Your Application   © 2012 IBM Corporation
Goals of this talk



■   Deliver an insight into the memory usage of Java code:
     – The overhead of Java Objects
     – The cost of delegation
     – The overhead of the common Java Collections



■   Provide you with information to:
      – Choose the right collection types
      – Analyze your application for memory inefficiencies




4                         From Java Code to Java Heap: Understanding the Memory Usage of Your Application   © 2012 IBM Corporation
Agenda



■   Introduction to Memory Management


■   Anatomy of a Java object


■   Understanding Java Collections


■   Analyzing your application




5                         From Java Code to Java Heap: Understanding the Memory Usage of Your Application   © 2012 IBM Corporation
Understanding Java Memory Management



■   Java runs as a Operating System (OS) level process, with the restrictions that the OS
    imposes:
         0 GB                                                  2 GB                                              4 GB
                                                                                                  -Xmx


           OS and C-Runtime JVM Native Heap                                                Java Heap(s)

                           0x40000000                                                       0xC0000000
         0x0                                              0x80000000                                           0xFFFFFFFF

■   32 bit architecture and/or OS gives 4GB of process address space
      – Much, much larger for 64bit
■   Some memory is used by the OS and C-language runtime
     – Area left over is termed the “User Space”
■   Some memory is used by the Java Virtual Machine (JVM) runtime
■   Some of the rest is used for the Java Heap(s)
               …and some is left over: the “native” heap
■   Native heap is usually measured including the JVM memory usage

6                            From Java Code to Java Heap: Understanding the Memory Usage of Your Application            © 2012 IBM Corporation
Anatomy of a Java Object



■   A Java Object consists of:
      – Object data (fields)
         • boolean, byte, char, short, int, float, long, double and object references
      – Object metadata
         • describes the Object data

■   Question:        What is the size ratio of a Integer object, to an int value?
                     (for a 32bit platform)
         (a) 1 : 1

         (b) 1.5 : 1

         (c) 2 : 1

         (d) 3: 1




7                               From Java Code to Java Heap: Understanding the Memory Usage of Your Application   © 2012 IBM Corporation
Anatomy of a Java Object



■   A Java Object consists of:
      – Object data (fields)
         • boolean, byte, char, short, int, float, long, double and object references
      – Object metadata
         • describes the Object data

■   Question:        What is the size ratio of a Integer object, to an int value?
                     (for a 32bit platform)
         (a) 1 : 1

         (b) 1.5 : 1

         (c) 2 : 1

         (d) 3: 1
■   Answer is option (e) 4 : 1 !!


8                               From Java Code to Java Heap: Understanding the Memory Usage of Your Application   © 2012 IBM Corporation
Object Field Sizes


       Field Type                                                      Field size/bits
                                                 32bit Process                                64bit Process
                                              Object                  Array               Object                Array
       boolean                              32                    8                     32                  8
       byte                                 32                    8                     32                  8
       char                                 32                    16                    32                  16
       short                                32                    16                    32                  16
       int                                  32                    32                    32                  32
       float                                32                    32                    32                  32
       long                                 64                    64                    64                  64
       double                               64                    64                    64                  64
       Objects                              32                    32                    64*                 64
       *32bits if Compressed References / Compressed Oops enabled


9                         From Java Code to Java Heap: Understanding the Memory Usage of Your Application               © 2012 IBM Corporation
Anatomy of a Java Object



■    Object Metadata: 3 slots of data (4 for arrays)
      – Class:   pointer to class information
      – Flags:   shape, hash code, etc
      – Lock:    flatlock or pointer to inflated monitor
      – Size:    the length of the array      (arrays only)
                                                                            Size/Bits
    0              32           64           96             128              160              192             224        256   288           320


        Class pointer   Flags        Locks            int                                                                        Java Object


        Class pointer   Flags        Locks           Size             int                                                       Array Object




■    Additionally, all Objects are 8 byte aligned (16 byte for CompressedOops with large heaps)



10                                     From Java Code to Java Heap: Understanding the Memory Usage of Your Application         © 2012 IBM Corporation
Anatomy of a 64bit Java Object



■    Object Metadata: 3 slots of data (4 for arrays)
      – Class:   pointer to class information
      – Flags:   shape, hash code, etc
      – Lock:    flatlock or pointer to inflated monitor
      – Size:    the length of the array      (arrays only)
                                                                               Size/Bits
    0              32              64           96             128              160              192             224        256         288           320


        Class pointer pointer
               Class       Flags        Locks Flags      int                    Locks                      int                            Java Object


        Class pointer pointer
               Class       Flags        Locks Flags     Size             int    Locks                             Size            int    Array Object




■    Size ratio of an Integer object to an int value becomes 9:1 !!



11                                        From Java Code to Java Heap: Understanding the Memory Usage of Your Application               © 2012 IBM Corporation
Compressed References and CompressedOOPs



■    Migrating an application from 32bit to 64bit Java increases memory usage:
      – Java heap usage increases by ~70%
      – “Native” heap usage increases by ~90%

■    Compressed References / Compressed Ordinary Object Pointers
      – Use bit shifted, relative addressing for 64bit Java heaps
      – Object metadata and Objects references become 32bits

■    Using compressed technologies does remove Java heap usage increase
■    Using compressed technologies does not remove “native” heap usage increase




12                         From Java Code to Java Heap: Understanding the Memory Usage of Your Application   © 2012 IBM Corporation
Allocating (slightly) more complex objects



■    Good object orientated design encourages encapsulation and delegation


■    Simple example: java.lang.String containing “MyString”:

                                                                          Size/Bits
    0              32           64           96             128              160              192             224            256      288            320


        Class pointer   Flags        Locks          hash             count           offset           value                        java.lang.String



        Class pointer   Flags        Locks           Size        char     char    char     char     char    char     char   char   char[]



■    128 bits of char data, stored in 480 bits of memory, size ratio of 3.75 : 1
       – Maximum overhead would be 24:1 for a single character!

13                                     From Java Code to Java Heap: Understanding the Memory Usage of Your Application                 © 2012 IBM Corporation
Java Collections



■    Each Java Collection has a different level of function, and memory overhead
                                                    HashSet
                              Increasing Function




                                                                             Increasing Size
                                                    HashMap
                                                    Hashtable
                                                    LinkedList
                                                    ArrayList
■    Using the wrong type of collection can incur significant additional memory overhead




14                         From Java Code to Java Heap: Understanding the Memory Usage of Your Application   © 2012 IBM Corporation
HashSet



■    Implementation of the Set interface
       – “A collection that contains no duplicate elements. More formally, sets contain no pair of
         elements e1 and e2 such that e1.equals(e2), and at most one null element. As implied
         by its name, this interface models the mathematical set abstraction. “
           • Java Platform SE 6 API doc

■    Implementation is a wrapper around a HashMap:




■    Default capacity for HashSet is 16
■    Empty size is 144 bytes
■    Additional 16 bytes / 128 bits overhead for wrappering over HashMap


15                          From Java Code to Java Heap: Understanding the Memory Usage of Your Application   © 2012 IBM Corporation
HashMap



■    Implementation of the Map interface:
       – “An object that maps keys to values. A map cannot contain duplicate keys; each key can
         map to at most one value.“
           • Java Platform SE 6 API doc

■    Implementation is an array of HashMap$Entry objects:




■    Default capacity is 16 entries
■    Empty size is 128 bytes
■    Overhead is 48 bytes for HashMap, plus (16 + (entries * 4bytes)) for array
      – Plus overhead of HashMap$Entry objects


16                          From Java Code to Java Heap: Understanding the Memory Usage of Your Application   © 2012 IBM Corporation
HashMap$Entry



■    Each HashMap$Entry contains:
      – int     KeyHash
      – Object  next
      – Object  key
      – Object  value

■    Additional 32bytes per key ↔ value entry
■    Overhead of HashMap is therefore:
      – 48 bytes, plus 36 bytes per entry

■    For a 10,000 entry HashMap, the overhead is ~360K




17                         From Java Code to Java Heap: Understanding the Memory Usage of Your Application   © 2012 IBM Corporation
Hashtable



■    Implementation of the Map interface:
       – “This class implements a hashtable, which maps keys to values. Any non-null object can
         be used as a key or as a value.“
           • Java Platform SE 6 API doc

■    Implementation is an array of Hashtable$Entry objects:




■    Default capacity is 11 entries
■    Empty size is 104 bytes
■    Overhead is 40 bytes for Hashtable, plus (16 + (entries * 4bytes)) for array
      – Plus overhead of Hashtable$Entry objects


18                          From Java Code to Java Heap: Understanding the Memory Usage of Your Application   © 2012 IBM Corporation
Hashtable$Entry



■    Each Hashtable$Entry contains:
      – int      KeyHash
      – Object   next
      – Object   key
      – Object   value

■    Additional 32bytes per key ↔ value entry
■    Overhead of Hashtable is therefore:
      – 40 bytes, plus 36 bytes per entry

■    For a 10,000 entry Hashtable, the overhead is ~360K




19                         From Java Code to Java Heap: Understanding the Memory Usage of Your Application   © 2012 IBM Corporation
LinkedList



■    Linked list implementation of the List interface:
       – “An ordered collection (also known as a sequence). The user of this interface has
         precise control over where in the list each element is inserted. The user can access
         elements by their integer index (position in the list), and search for elements in the list.
       – Unlike sets, lists typically allow duplicate elements. “
           • Java Platform SE 6 API doc

■    Implementation is a linked list of LinkedList$Entry objects (or LinkedList$Link):




■    Default capacity is 1 entry
■    Empty size is 48 bytes
■    Overhead is 24 bytes for LinkedList, plus overhead of LinkedList$Entry/Link objects



20                            From Java Code to Java Heap: Understanding the Memory Usage of Your Application   © 2012 IBM Corporation
LinkedList$Entry / Link



■    Each LinkedList$Entry contains:
      – Object   previous
      – Object   next
      – Object   entry

■    Additional 24bytes per entry
■    Overhead of LinkedList is therefore:
      – 24 bytes, plus 24 bytes per entry

■    For a 10,000 entry LinkedList, the overhead is ~240K




21                         From Java Code to Java Heap: Understanding the Memory Usage of Your Application   © 2012 IBM Corporation
ArrayList



■    A resizeable array instance of the List interface:
       – “An ordered collection (also known as a sequence). The user of this interface has
         precise control over where in the list each element is inserted. The user can access
         elements by their integer index (position in the list), and search for elements in the list.
       – Unlike sets, lists typically allow duplicate elements. “
           • Java Platform SE 6 API doc


■    Implementation is an array of Object:




■    Default capacity is 10 entries
■    Empty size is 88 bytes
■    Overhead is 32bytes for ArrayList, plus (16 + (entries * 4bytes)) for array
■    For a 10,000 entry ArrayList, the overhead is ~40K
22                            From Java Code to Java Heap: Understanding the Memory Usage of Your Application   © 2012 IBM Corporation
Other types of “Collections”



■    StringBuffers can be considered to be a type of collection
       – “A thread-safe, mutable sequence of characters...
         ....
       – Every string buffer has a capacity. As long as the length of the character sequence
         contained in the string buffer does not exceed the capacity, it is not necessary to
         allocate a new internal buffer array. If the internal buffer overflows, it is automatically
         made larger.”
            • Java Platform SE 6 API doc

■    Implementation is an array of char




■    Default capacity is 16 characters
■    Empty size is 72 bytes
■    Overhead is just 24bytes for StringBuffer

23                            From Java Code to Java Heap: Understanding the Memory Usage of Your Application   © 2012 IBM Corporation
Empty space in collections



■     Collections that contain empty space introduce additional overhead
       – Low “Fill Ratio”

■     Default collection size may not be appropriate for the amount of data being held


0        32       64       96       128       160   192     224      256    288      320      352      384     416    448      480    512   544     576   608    640




     Class    Flags    Locks    count     value                                                                                                   java.lang.StringBuffer



     Class    Flags    Locks    Size charcharcharcharcharcharcharchar charcharcharcharcharcharcharchar
                                      M Y         S T R I N G                                                                                                          char[]

■     StringBuffer default of 16 is inappropriate to hold a 9 character string
        – 7 additional entries in char[]
        – 112 byte additional overhead

24                                                  From Java Code to Java Heap: Understanding the Memory Usage of Your Application                        © 2012 IBM Corporation
Expansion of collections



■     When collections hit the limit of their capacity, they expand
       – Greatly increases capacity
       – Greatly reduces “fill ratio”

■     Introduces additional collection overhead:
0        32       64       96       128       160   192     224      256    288      320      352      384     416    448      480    512   544     576   608     640




     Class    Flags    Locks    count     value                                                                                                   java.lang.StringBuffer



     Class    Flags    Locks    Size charcharcharcharcharcharcharchar charcharcharcharcharcharcharcharcharcharcharcharcharcharchar charcharcharcharcharcharcharchar
                                      M Y         S T R I N G                  O F         T E X T                                                                      char[]



■     Additional 16 char[] entries to hold single extra character
       – 240 byte additional overhead

25                                                  From Java Code to Java Heap: Understanding the Memory Usage of Your Application                         © 2012 IBM Corporation
Collections Summary




     Collection     Default                       Empty Size                       10K Entry               Expansion
                    Capacity                                                       Overhead                Algorithm
     HashSet        16                            144                              360K                    double size
     HashMap        16                            128                              360K                    double size
     Hashtable      11                            104                              360K                    double size + 1
     LinkedList     1                             48                               240K                    single entries
     ArrayList      10                            88                               40K                     size + 50%
     StringBuffer   16                            72                               24                      double size




26                       From Java Code to Java Heap: Understanding the Memory Usage of Your Application           © 2012 IBM Corporation
Collections Summary



■    Collections exist in large numbers in many Java applications


■    Example: IBM WebSphere Application Server running PlantsByWebSphere
      – When running a 5 user test load, and using 206MB of Java heap:
           HashTable           262,234 instances,      26.5MB of Java heap
           WeakHashMap         19,562 instances        2.6MB     of Java heap
           HashMap             10,600 instances        2.3MB     of Java heap
           ArrayList           9,530      instances    0.3MB     of Java heap
           HashSet             1,551      instances    1.0MB     of Java heap
           Vector              1,271      instances    0.04MB of Java heap
           LinkedList          1,148      instances    0.1MB     of Java heap
           TreeMap             299        instances    0.03MB of Java heap
                               306,195                 32.9MB

■    16% of the Java heap used just for the collection objects !!



27                          From Java Code to Java Heap: Understanding the Memory Usage of Your Application   © 2012 IBM Corporation
Analyzing your Collections



■    Eclipse Memory Analyzer Tool (MAT) provides Collection analysis:




28                         From Java Code to Java Heap: Understanding the Memory Usage of Your Application   © 2012 IBM Corporation
Analyzing your DirectByteBuffers



■    IBM Extensions for Memory Analyzer (IEMA) provides DirectByteBuffer analysis:




29                        From Java Code to Java Heap: Understanding the Memory Usage of Your Application   © 2012 IBM Corporation
Summary



■    There is significant overhead to your data!
      – Some of which is on the “native” heap

■    Applications often have:
      – The wrong collection types in use
      – Empty or sparsely populated collections

■    Careful use of:
      – Data structure layout
      – Collection type selection
      – Collection type default sizing
     Can improve your memory efficiency


■    Eclipse Memory Analyzer Tool can identify inefficiencies in your application
      – As well as show you the wider memory usage for code

30                          From Java Code to Java Heap: Understanding the Memory Usage of Your Application   © 2012 IBM Corporation
Read the Article:




            From Java Code to Java Heap on IBM developerWorks:
       http://www.ibm.com/developerworks/java/library/j-codetoheap/index.html




31                   From Java Code to Java Heap: Understanding the Memory Usage of Your Application   © 2012 IBM Corporation
References



■    Get Products and Technologies:
      – IBM Monitoring and Diagnostic Tools for Java:
          • https://www.ibm.com/developerworks/java/jdk/tools/
      – Eclipse Memory Analyzer Tool:
          • http://eclipse.org/mat/downloads.php

■    Learn:
      – Debugging from Dumps:
          • http://www.ibm.com/developerworks/java/library/j-memoryanalyzer/index.html
      – Why the Memory Analyzer (with IBM Extensions) isn't just for memory leaks anymore:
          • http://www.ibm.com/developerworks/websphere/techjournal/1103_supauth/1103_sup
            auth.html
■    Discuss:
      – IBM on Troubleshooting Java Applications Blog:
          • https://www.ibm.com/developerworks/mydeveloperworks/blogs/troubleshootingjava/
      – IBM Java Runtimes and SDKs Forum:
          • http://www.ibm.com/developerworks/forums/forum.jspa?forumID=367&start=0

32                         From Java Code to Java Heap: Understanding the Memory Usage of Your Application   © 2012 IBM Corporation
Copyright and Trademarks



© IBM Corporation 2012. All Rights Reserved.


IBM, the IBM logo, and ibm.com are trademarks or registered trademarks of International
Business Machines Corp., and registered in many jurisdictions worldwide.


Other product and service names might be trademarks of IBM or other companies.


A current list of IBM trademarks is available on the Web – see the IBM “Copyright and
trademark information” page at URL: www.ibm.com/legal/copytrade.shtml




33                      From Java Code to Java Heap: Understanding the Memory Usage of Your Application   © 2012 IBM Corporation

More Related Content

What's hot

Rapid JCR applications development with Sling
Rapid JCR applications development with SlingRapid JCR applications development with Sling
Rapid JCR applications development with SlingBertrand Delacretaz
 
Spark and Shark: Lightning-Fast Analytics over Hadoop and Hive Data
Spark and Shark: Lightning-Fast Analytics over Hadoop and Hive DataSpark and Shark: Lightning-Fast Analytics over Hadoop and Hive Data
Spark and Shark: Lightning-Fast Analytics over Hadoop and Hive DataJetlore
 
KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB
KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB
KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB Rakuten Group, Inc.
 
Towards JVM Dynamic Languages Toolchain
Towards JVM Dynamic Languages ToolchainTowards JVM Dynamic Languages Toolchain
Towards JVM Dynamic Languages ToolchainAttila Szegedi
 
Java Future S Ritter
Java Future S RitterJava Future S Ritter
Java Future S Rittercatherinewall
 
Know yourengines velocity2011
Know yourengines velocity2011Know yourengines velocity2011
Know yourengines velocity2011Demis Bellot
 
Transparent GPU Exploitation for Java
Transparent GPU Exploitation for JavaTransparent GPU Exploitation for Java
Transparent GPU Exploitation for JavaKazuaki Ishizaki
 
Why databases cry at night
Why databases cry at nightWhy databases cry at night
Why databases cry at nightMichael Yarichuk
 
iOS Multithreading
iOS MultithreadingiOS Multithreading
iOS MultithreadingRicha Jain
 
Hadoop Summit - Hausenblas 20 March
Hadoop Summit - Hausenblas 20 MarchHadoop Summit - Hausenblas 20 March
Hadoop Summit - Hausenblas 20 MarchMapR Technologies
 
Top 30 Node.js interview questions
Top 30 Node.js interview questionsTop 30 Node.js interview questions
Top 30 Node.js interview questionstechievarsity
 
Software Profiling: Understanding Java Performance and how to profile in Java
Software Profiling: Understanding Java Performance and how to profile in JavaSoftware Profiling: Understanding Java Performance and how to profile in Java
Software Profiling: Understanding Java Performance and how to profile in JavaIsuru Perera
 
[JavaOne 2011] Models for Concurrent Programming
[JavaOne 2011] Models for Concurrent Programming[JavaOne 2011] Models for Concurrent Programming
[JavaOne 2011] Models for Concurrent ProgrammingTobias Lindaaker
 
Java New Evolution
Java New EvolutionJava New Evolution
Java New EvolutionAllan Huang
 
Hong Qiangning in QConBeijing
Hong Qiangning in QConBeijingHong Qiangning in QConBeijing
Hong Qiangning in QConBeijingshen liu
 
Ts archiving
Ts   archivingTs   archiving
Ts archivingConfiz
 
Java Performance & Profiling
Java Performance & ProfilingJava Performance & Profiling
Java Performance & ProfilingIsuru Perera
 

What's hot (20)

Rapid JCR applications development with Sling
Rapid JCR applications development with SlingRapid JCR applications development with Sling
Rapid JCR applications development with Sling
 
Spark and Shark: Lightning-Fast Analytics over Hadoop and Hive Data
Spark and Shark: Lightning-Fast Analytics over Hadoop and Hive DataSpark and Shark: Lightning-Fast Analytics over Hadoop and Hive Data
Spark and Shark: Lightning-Fast Analytics over Hadoop and Hive Data
 
KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB
KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB
KVSの性能、RDBMSのインデックス、更にMapReduceを併せ持つAll-in-One NoSQL: MongoDB
 
The Internals of "Hello World" Program
The Internals of "Hello World" ProgramThe Internals of "Hello World" Program
The Internals of "Hello World" Program
 
Towards JVM Dynamic Languages Toolchain
Towards JVM Dynamic Languages ToolchainTowards JVM Dynamic Languages Toolchain
Towards JVM Dynamic Languages Toolchain
 
Java Future S Ritter
Java Future S RitterJava Future S Ritter
Java Future S Ritter
 
How to Test Asynchronous Code
How to Test Asynchronous CodeHow to Test Asynchronous Code
How to Test Asynchronous Code
 
Know yourengines velocity2011
Know yourengines velocity2011Know yourengines velocity2011
Know yourengines velocity2011
 
Transparent GPU Exploitation for Java
Transparent GPU Exploitation for JavaTransparent GPU Exploitation for Java
Transparent GPU Exploitation for Java
 
Why databases cry at night
Why databases cry at nightWhy databases cry at night
Why databases cry at night
 
iOS Multithreading
iOS MultithreadingiOS Multithreading
iOS Multithreading
 
Hadoop Summit - Hausenblas 20 March
Hadoop Summit - Hausenblas 20 MarchHadoop Summit - Hausenblas 20 March
Hadoop Summit - Hausenblas 20 March
 
Top 30 Node.js interview questions
Top 30 Node.js interview questionsTop 30 Node.js interview questions
Top 30 Node.js interview questions
 
Software Profiling: Understanding Java Performance and how to profile in Java
Software Profiling: Understanding Java Performance and how to profile in JavaSoftware Profiling: Understanding Java Performance and how to profile in Java
Software Profiling: Understanding Java Performance and how to profile in Java
 
[JavaOne 2011] Models for Concurrent Programming
[JavaOne 2011] Models for Concurrent Programming[JavaOne 2011] Models for Concurrent Programming
[JavaOne 2011] Models for Concurrent Programming
 
Java New Evolution
Java New EvolutionJava New Evolution
Java New Evolution
 
Hong Qiangning in QConBeijing
Hong Qiangning in QConBeijingHong Qiangning in QConBeijing
Hong Qiangning in QConBeijing
 
Methods of NoSQL database systems benchmarking
Methods of NoSQL database systems benchmarkingMethods of NoSQL database systems benchmarking
Methods of NoSQL database systems benchmarking
 
Ts archiving
Ts   archivingTs   archiving
Ts archiving
 
Java Performance & Profiling
Java Performance & ProfilingJava Performance & Profiling
Java Performance & Profiling
 

Similar to From Java code to Java heap: Understanding and optimizing your application's memory usage

From Java Code to Java Heap: Understanding the Memory Usage of Your App - Ch...
From Java Code to Java Heap: Understanding the Memory Usage of Your App  - Ch...From Java Code to Java Heap: Understanding the Memory Usage of Your App  - Ch...
From Java Code to Java Heap: Understanding the Memory Usage of Your App - Ch...jaxLondonConference
 
Everything I Ever Learned About JVM Performance Tuning @Twitter
Everything I Ever Learned About JVM Performance Tuning @TwitterEverything I Ever Learned About JVM Performance Tuning @Twitter
Everything I Ever Learned About JVM Performance Tuning @TwitterAttila Szegedi
 
Case Study: Porting a set of point cloud and triangle mesh processing C++ lib...
Case Study: Porting a set of point cloud and triangle mesh processing C++ lib...Case Study: Porting a set of point cloud and triangle mesh processing C++ lib...
Case Study: Porting a set of point cloud and triangle mesh processing C++ lib...PVS-Studio
 
"Source Code Abstracts Classification Using CNN", Vadim Markovtsev, Lead Soft...
"Source Code Abstracts Classification Using CNN", Vadim Markovtsev, Lead Soft..."Source Code Abstracts Classification Using CNN", Vadim Markovtsev, Lead Soft...
"Source Code Abstracts Classification Using CNN", Vadim Markovtsev, Lead Soft...Dataconomy Media
 
Dynamic Languages in Production: Progress and Open Challenges
Dynamic Languages in Production: Progress and Open ChallengesDynamic Languages in Production: Progress and Open Challenges
Dynamic Languages in Production: Progress and Open Challengesbcantrill
 
The Performance Engineer's Guide To HotSpot Just-in-Time Compilation
The Performance Engineer's Guide To HotSpot Just-in-Time CompilationThe Performance Engineer's Guide To HotSpot Just-in-Time Compilation
The Performance Engineer's Guide To HotSpot Just-in-Time CompilationMonica Beckwith
 
’new’ in JVM -- What happen when ’new’ is called?
’new’ in JVM -- What happen when ’new’ is called?’new’ in JVM -- What happen when ’new’ is called?
’new’ in JVM -- What happen when ’new’ is called?Kengo Toda
 
Memory Analysis of the Dalvik (Android) Virtual Machine
Memory Analysis of the Dalvik (Android) Virtual MachineMemory Analysis of the Dalvik (Android) Virtual Machine
Memory Analysis of the Dalvik (Android) Virtual MachineAndrew Case
 
Pitfalls of Object Oriented Programming by SONY
Pitfalls of Object Oriented Programming by SONYPitfalls of Object Oriented Programming by SONY
Pitfalls of Object Oriented Programming by SONYAnaya Medias Swiss
 
JavaOne 2016: Getting Started with Apache Spark: Use Scala, Java, Python, or ...
JavaOne 2016: Getting Started with Apache Spark: Use Scala, Java, Python, or ...JavaOne 2016: Getting Started with Apache Spark: Use Scala, Java, Python, or ...
JavaOne 2016: Getting Started with Apache Spark: Use Scala, Java, Python, or ...David Taieb
 
Deep Dive into Project Tungsten: Bringing Spark Closer to Bare Metal-(Josh Ro...
Deep Dive into Project Tungsten: Bringing Spark Closer to Bare Metal-(Josh Ro...Deep Dive into Project Tungsten: Bringing Spark Closer to Bare Metal-(Josh Ro...
Deep Dive into Project Tungsten: Bringing Spark Closer to Bare Metal-(Josh Ro...Spark Summit
 
Advanced High-Performance Computing Features of the OpenPOWER ISA
 Advanced High-Performance Computing Features of the OpenPOWER ISA Advanced High-Performance Computing Features of the OpenPOWER ISA
Advanced High-Performance Computing Features of the OpenPOWER ISAGanesan Narayanasamy
 
SF Big Analytics & SF Machine Learning Meetup: Machine Learning at the Limit ...
SF Big Analytics & SF Machine Learning Meetup: Machine Learning at the Limit ...SF Big Analytics & SF Machine Learning Meetup: Machine Learning at the Limit ...
SF Big Analytics & SF Machine Learning Meetup: Machine Learning at the Limit ...Chester Chen
 
Java tuning on GNU/Linux for busy dev
Java tuning on GNU/Linux for busy devJava tuning on GNU/Linux for busy dev
Java tuning on GNU/Linux for busy devTomek Borek
 
Accelerating NLP with Dask on Saturn Cloud: A case study with CORD-19
Accelerating NLP with Dask on Saturn Cloud: A case study with CORD-19Accelerating NLP with Dask on Saturn Cloud: A case study with CORD-19
Accelerating NLP with Dask on Saturn Cloud: A case study with CORD-19Sujit Pal
 

Similar to From Java code to Java heap: Understanding and optimizing your application's memory usage (20)

From Java Code to Java Heap: Understanding the Memory Usage of Your App - Ch...
From Java Code to Java Heap: Understanding the Memory Usage of Your App  - Ch...From Java Code to Java Heap: Understanding the Memory Usage of Your App  - Ch...
From Java Code to Java Heap: Understanding the Memory Usage of Your App - Ch...
 
Everything I Ever Learned About JVM Performance Tuning @Twitter
Everything I Ever Learned About JVM Performance Tuning @TwitterEverything I Ever Learned About JVM Performance Tuning @Twitter
Everything I Ever Learned About JVM Performance Tuning @Twitter
 
Case Study: Porting a set of point cloud and triangle mesh processing C++ lib...
Case Study: Porting a set of point cloud and triangle mesh processing C++ lib...Case Study: Porting a set of point cloud and triangle mesh processing C++ lib...
Case Study: Porting a set of point cloud and triangle mesh processing C++ lib...
 
"Source Code Abstracts Classification Using CNN", Vadim Markovtsev, Lead Soft...
"Source Code Abstracts Classification Using CNN", Vadim Markovtsev, Lead Soft..."Source Code Abstracts Classification Using CNN", Vadim Markovtsev, Lead Soft...
"Source Code Abstracts Classification Using CNN", Vadim Markovtsev, Lead Soft...
 
Eusecwest
EusecwestEusecwest
Eusecwest
 
Surge2012
Surge2012Surge2012
Surge2012
 
Loom promises: be there!
Loom promises: be there!Loom promises: be there!
Loom promises: be there!
 
Dynamic Languages in Production: Progress and Open Challenges
Dynamic Languages in Production: Progress and Open ChallengesDynamic Languages in Production: Progress and Open Challenges
Dynamic Languages in Production: Progress and Open Challenges
 
The Performance Engineer's Guide To HotSpot Just-in-Time Compilation
The Performance Engineer's Guide To HotSpot Just-in-Time CompilationThe Performance Engineer's Guide To HotSpot Just-in-Time Compilation
The Performance Engineer's Guide To HotSpot Just-in-Time Compilation
 
’new’ in JVM -- What happen when ’new’ is called?
’new’ in JVM -- What happen when ’new’ is called?’new’ in JVM -- What happen when ’new’ is called?
’new’ in JVM -- What happen when ’new’ is called?
 
Memory Analysis of the Dalvik (Android) Virtual Machine
Memory Analysis of the Dalvik (Android) Virtual MachineMemory Analysis of the Dalvik (Android) Virtual Machine
Memory Analysis of the Dalvik (Android) Virtual Machine
 
Pitfalls of Object Oriented Programming by SONY
Pitfalls of Object Oriented Programming by SONYPitfalls of Object Oriented Programming by SONY
Pitfalls of Object Oriented Programming by SONY
 
JavaOne 2016: Getting Started with Apache Spark: Use Scala, Java, Python, or ...
JavaOne 2016: Getting Started with Apache Spark: Use Scala, Java, Python, or ...JavaOne 2016: Getting Started with Apache Spark: Use Scala, Java, Python, or ...
JavaOne 2016: Getting Started with Apache Spark: Use Scala, Java, Python, or ...
 
Deep Dive into Project Tungsten: Bringing Spark Closer to Bare Metal-(Josh Ro...
Deep Dive into Project Tungsten: Bringing Spark Closer to Bare Metal-(Josh Ro...Deep Dive into Project Tungsten: Bringing Spark Closer to Bare Metal-(Josh Ro...
Deep Dive into Project Tungsten: Bringing Spark Closer to Bare Metal-(Josh Ro...
 
64 bits for developers
64 bits for developers64 bits for developers
64 bits for developers
 
Advanced High-Performance Computing Features of the OpenPOWER ISA
 Advanced High-Performance Computing Features of the OpenPOWER ISA Advanced High-Performance Computing Features of the OpenPOWER ISA
Advanced High-Performance Computing Features of the OpenPOWER ISA
 
SF Big Analytics & SF Machine Learning Meetup: Machine Learning at the Limit ...
SF Big Analytics & SF Machine Learning Meetup: Machine Learning at the Limit ...SF Big Analytics & SF Machine Learning Meetup: Machine Learning at the Limit ...
SF Big Analytics & SF Machine Learning Meetup: Machine Learning at the Limit ...
 
64 bit arch
64 bit arch64 bit arch
64 bit arch
 
Java tuning on GNU/Linux for busy dev
Java tuning on GNU/Linux for busy devJava tuning on GNU/Linux for busy dev
Java tuning on GNU/Linux for busy dev
 
Accelerating NLP with Dask on Saturn Cloud: A case study with CORD-19
Accelerating NLP with Dask on Saturn Cloud: A case study with CORD-19Accelerating NLP with Dask on Saturn Cloud: A case study with CORD-19
Accelerating NLP with Dask on Saturn Cloud: A case study with CORD-19
 

More from Chris Bailey

NodeJS Interactive 2019: FaaS meets Frameworks
NodeJS Interactive 2019:  FaaS meets FrameworksNodeJS Interactive 2019:  FaaS meets Frameworks
NodeJS Interactive 2019: FaaS meets FrameworksChris Bailey
 
Voxxed Micro-services: Serverless JakartaEE - JAX-RS comes to FaaS
Voxxed Micro-services: Serverless JakartaEE - JAX-RS comes to FaaSVoxxed Micro-services: Serverless JakartaEE - JAX-RS comes to FaaS
Voxxed Micro-services: Serverless JakartaEE - JAX-RS comes to FaaSChris Bailey
 
Silicon Valley Code Camp 2019 - Reaching the Cloud Native World
Silicon Valley Code Camp 2019 - Reaching the Cloud Native WorldSilicon Valley Code Camp 2019 - Reaching the Cloud Native World
Silicon Valley Code Camp 2019 - Reaching the Cloud Native WorldChris Bailey
 
FaaS Meets Java EE: Developing Cloud Native Applications at Speed
FaaS Meets Java EE: Developing Cloud Native Applications at SpeedFaaS Meets Java EE: Developing Cloud Native Applications at Speed
FaaS Meets Java EE: Developing Cloud Native Applications at SpeedChris Bailey
 
AltConf 2019: Server-Side Swift State of the Union
AltConf 2019:  Server-Side Swift State of the UnionAltConf 2019:  Server-Side Swift State of the Union
AltConf 2019: Server-Side Swift State of the UnionChris Bailey
 
Server-side Swift with Swagger
Server-side Swift with SwaggerServer-side Swift with Swagger
Server-side Swift with SwaggerChris Bailey
 
Node Summit 2018: Cloud Native Node.js
Node Summit 2018: Cloud Native Node.jsNode Summit 2018: Cloud Native Node.js
Node Summit 2018: Cloud Native Node.jsChris Bailey
 
Index - BFFs vs GraphQL
Index - BFFs vs GraphQLIndex - BFFs vs GraphQL
Index - BFFs vs GraphQLChris Bailey
 
Swift Cloud Workshop - Swift Microservices
Swift Cloud Workshop - Swift MicroservicesSwift Cloud Workshop - Swift Microservices
Swift Cloud Workshop - Swift MicroservicesChris Bailey
 
Swift Cloud Workshop - Codable, the key to Fullstack Swift
Swift Cloud Workshop - Codable, the key to Fullstack SwiftSwift Cloud Workshop - Codable, the key to Fullstack Swift
Swift Cloud Workshop - Codable, the key to Fullstack SwiftChris Bailey
 
Try!Swift India 2017: All you need is Swift
Try!Swift India 2017: All you need is SwiftTry!Swift India 2017: All you need is Swift
Try!Swift India 2017: All you need is SwiftChris Bailey
 
Swift Summit 2017: Server Swift State of the Union
Swift Summit 2017: Server Swift State of the UnionSwift Summit 2017: Server Swift State of the Union
Swift Summit 2017: Server Swift State of the UnionChris Bailey
 
IBM Cloud University: Build, Deploy and Scale Node.js Microservices
IBM Cloud University: Build, Deploy and Scale Node.js MicroservicesIBM Cloud University: Build, Deploy and Scale Node.js Microservices
IBM Cloud University: Build, Deploy and Scale Node.js MicroservicesChris Bailey
 
IBM Cloud University: Java, Node.js and Swift
IBM Cloud University: Java, Node.js and SwiftIBM Cloud University: Java, Node.js and Swift
IBM Cloud University: Java, Node.js and SwiftChris Bailey
 
Node Interactive: Node.js Performance and Highly Scalable Micro-Services
Node Interactive: Node.js Performance and Highly Scalable Micro-ServicesNode Interactive: Node.js Performance and Highly Scalable Micro-Services
Node Interactive: Node.js Performance and Highly Scalable Micro-ServicesChris Bailey
 
FrenchKit 2017: Server(less) Swift
FrenchKit 2017: Server(less) SwiftFrenchKit 2017: Server(less) Swift
FrenchKit 2017: Server(less) SwiftChris Bailey
 
AltConf 2017: Full Stack Swift in 30 Minutes
AltConf 2017: Full Stack Swift in 30 MinutesAltConf 2017: Full Stack Swift in 30 Minutes
AltConf 2017: Full Stack Swift in 30 MinutesChris Bailey
 
InterConnect: Server Side Swift for Java Developers
InterConnect:  Server Side Swift for Java DevelopersInterConnect:  Server Side Swift for Java Developers
InterConnect: Server Side Swift for Java DevelopersChris Bailey
 
InterConnect: Java, Node.js and Swift - Which, Why and When
InterConnect: Java, Node.js and Swift - Which, Why and WhenInterConnect: Java, Node.js and Swift - Which, Why and When
InterConnect: Java, Node.js and Swift - Which, Why and WhenChris Bailey
 
Playgrounds: Mobile + Swift = BFF
Playgrounds: Mobile + Swift = BFFPlaygrounds: Mobile + Swift = BFF
Playgrounds: Mobile + Swift = BFFChris Bailey
 

More from Chris Bailey (20)

NodeJS Interactive 2019: FaaS meets Frameworks
NodeJS Interactive 2019:  FaaS meets FrameworksNodeJS Interactive 2019:  FaaS meets Frameworks
NodeJS Interactive 2019: FaaS meets Frameworks
 
Voxxed Micro-services: Serverless JakartaEE - JAX-RS comes to FaaS
Voxxed Micro-services: Serverless JakartaEE - JAX-RS comes to FaaSVoxxed Micro-services: Serverless JakartaEE - JAX-RS comes to FaaS
Voxxed Micro-services: Serverless JakartaEE - JAX-RS comes to FaaS
 
Silicon Valley Code Camp 2019 - Reaching the Cloud Native World
Silicon Valley Code Camp 2019 - Reaching the Cloud Native WorldSilicon Valley Code Camp 2019 - Reaching the Cloud Native World
Silicon Valley Code Camp 2019 - Reaching the Cloud Native World
 
FaaS Meets Java EE: Developing Cloud Native Applications at Speed
FaaS Meets Java EE: Developing Cloud Native Applications at SpeedFaaS Meets Java EE: Developing Cloud Native Applications at Speed
FaaS Meets Java EE: Developing Cloud Native Applications at Speed
 
AltConf 2019: Server-Side Swift State of the Union
AltConf 2019:  Server-Side Swift State of the UnionAltConf 2019:  Server-Side Swift State of the Union
AltConf 2019: Server-Side Swift State of the Union
 
Server-side Swift with Swagger
Server-side Swift with SwaggerServer-side Swift with Swagger
Server-side Swift with Swagger
 
Node Summit 2018: Cloud Native Node.js
Node Summit 2018: Cloud Native Node.jsNode Summit 2018: Cloud Native Node.js
Node Summit 2018: Cloud Native Node.js
 
Index - BFFs vs GraphQL
Index - BFFs vs GraphQLIndex - BFFs vs GraphQL
Index - BFFs vs GraphQL
 
Swift Cloud Workshop - Swift Microservices
Swift Cloud Workshop - Swift MicroservicesSwift Cloud Workshop - Swift Microservices
Swift Cloud Workshop - Swift Microservices
 
Swift Cloud Workshop - Codable, the key to Fullstack Swift
Swift Cloud Workshop - Codable, the key to Fullstack SwiftSwift Cloud Workshop - Codable, the key to Fullstack Swift
Swift Cloud Workshop - Codable, the key to Fullstack Swift
 
Try!Swift India 2017: All you need is Swift
Try!Swift India 2017: All you need is SwiftTry!Swift India 2017: All you need is Swift
Try!Swift India 2017: All you need is Swift
 
Swift Summit 2017: Server Swift State of the Union
Swift Summit 2017: Server Swift State of the UnionSwift Summit 2017: Server Swift State of the Union
Swift Summit 2017: Server Swift State of the Union
 
IBM Cloud University: Build, Deploy and Scale Node.js Microservices
IBM Cloud University: Build, Deploy and Scale Node.js MicroservicesIBM Cloud University: Build, Deploy and Scale Node.js Microservices
IBM Cloud University: Build, Deploy and Scale Node.js Microservices
 
IBM Cloud University: Java, Node.js and Swift
IBM Cloud University: Java, Node.js and SwiftIBM Cloud University: Java, Node.js and Swift
IBM Cloud University: Java, Node.js and Swift
 
Node Interactive: Node.js Performance and Highly Scalable Micro-Services
Node Interactive: Node.js Performance and Highly Scalable Micro-ServicesNode Interactive: Node.js Performance and Highly Scalable Micro-Services
Node Interactive: Node.js Performance and Highly Scalable Micro-Services
 
FrenchKit 2017: Server(less) Swift
FrenchKit 2017: Server(less) SwiftFrenchKit 2017: Server(less) Swift
FrenchKit 2017: Server(less) Swift
 
AltConf 2017: Full Stack Swift in 30 Minutes
AltConf 2017: Full Stack Swift in 30 MinutesAltConf 2017: Full Stack Swift in 30 Minutes
AltConf 2017: Full Stack Swift in 30 Minutes
 
InterConnect: Server Side Swift for Java Developers
InterConnect:  Server Side Swift for Java DevelopersInterConnect:  Server Side Swift for Java Developers
InterConnect: Server Side Swift for Java Developers
 
InterConnect: Java, Node.js and Swift - Which, Why and When
InterConnect: Java, Node.js and Swift - Which, Why and WhenInterConnect: Java, Node.js and Swift - Which, Why and When
InterConnect: Java, Node.js and Swift - Which, Why and When
 
Playgrounds: Mobile + Swift = BFF
Playgrounds: Mobile + Swift = BFFPlaygrounds: Mobile + Swift = BFF
Playgrounds: Mobile + Swift = BFF
 

Recently uploaded

Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 

Recently uploaded (20)

Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 

From Java code to Java heap: Understanding and optimizing your application's memory usage

  • 1. Chris Bailey – IBM Java Service Architect 9th September 2012 From Java Code to Java Heap Understanding the Memory Usage of Your Application © 2012 IBM Corporation
  • 2. Important Disclaimers THE INFORMATION CONTAINED IN THIS PRESENTATION IS PROVIDED FOR INFORMATIONAL PURPOSES ONLY. WHILST EFFORTS WERE MADE TO VERIFY THE COMPLETENESS AND ACCURACY OF THE INFORMATION CONTAINED IN THIS PRESENTATION, IT IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED. ALL PERFORMANCE DATA INCLUDED IN THIS PRESENTATION HAVE BEEN GATHERED IN A CONTROLLED ENVIRONMENT. YOUR OWN TEST RESULTS MAY VARY BASED ON HARDWARE, SOFTWARE OR INFRASTRUCTURE DIFFERENCES. ALL DATA INCLUDED IN THIS PRESENTATION ARE MEANT TO BE USED ONLY AS A GUIDE. IN ADDITION, THE INFORMATION CONTAINED IN THIS PRESENTATION IS BASED ON IBM’S CURRENT PRODUCT PLANS AND STRATEGY, WHICH ARE SUBJECT TO CHANGE BY IBM, WITHOUT NOTICE. IBM AND ITS AFFILIATED COMPANIES SHALL NOT BE RESPONSIBLE FOR ANY DAMAGES ARISING OUT OF THE USE OF, OR OTHERWISE RELATED TO, THIS PRESENTATION OR ANY OTHER DOCUMENTATION. NOTHING CONTAINED IN THIS PRESENTATION IS INTENDED TO, OR SHALL HAVE THE EFFECT OF: - CREATING ANY WARRANT OR REPRESENTATION FROM IBM, ITS AFFILIATED COMPANIES OR ITS OR THEIR SUPPLIERS AND/OR LICENSORS 2 From Java Code to Java Heap: Understanding the Memory Usage of Your Application © 2012 IBM Corporation
  • 3. Introduction to the speaker ■ 12 years experience developing and deploying Java SDKs ■ Recent work focus: – Java usability and quality – Debugging tools and capabilities – Requirements gathering – Highly resilient and scalable deployments ■ My contact information: – baileyc@uk.ibm.com – http://www.linkedin.com/profile/view?id=3100666 3 From Java Code to Java Heap: Understanding the Memory Usage of Your Application © 2012 IBM Corporation
  • 4. Goals of this talk ■ Deliver an insight into the memory usage of Java code: – The overhead of Java Objects – The cost of delegation – The overhead of the common Java Collections ■ Provide you with information to: – Choose the right collection types – Analyze your application for memory inefficiencies 4 From Java Code to Java Heap: Understanding the Memory Usage of Your Application © 2012 IBM Corporation
  • 5. Agenda ■ Introduction to Memory Management ■ Anatomy of a Java object ■ Understanding Java Collections ■ Analyzing your application 5 From Java Code to Java Heap: Understanding the Memory Usage of Your Application © 2012 IBM Corporation
  • 6. Understanding Java Memory Management ■ Java runs as a Operating System (OS) level process, with the restrictions that the OS imposes: 0 GB 2 GB 4 GB -Xmx OS and C-Runtime JVM Native Heap Java Heap(s) 0x40000000 0xC0000000 0x0 0x80000000 0xFFFFFFFF ■ 32 bit architecture and/or OS gives 4GB of process address space – Much, much larger for 64bit ■ Some memory is used by the OS and C-language runtime – Area left over is termed the “User Space” ■ Some memory is used by the Java Virtual Machine (JVM) runtime ■ Some of the rest is used for the Java Heap(s) …and some is left over: the “native” heap ■ Native heap is usually measured including the JVM memory usage 6 From Java Code to Java Heap: Understanding the Memory Usage of Your Application © 2012 IBM Corporation
  • 7. Anatomy of a Java Object ■ A Java Object consists of: – Object data (fields) • boolean, byte, char, short, int, float, long, double and object references – Object metadata • describes the Object data ■ Question: What is the size ratio of a Integer object, to an int value? (for a 32bit platform) (a) 1 : 1 (b) 1.5 : 1 (c) 2 : 1 (d) 3: 1 7 From Java Code to Java Heap: Understanding the Memory Usage of Your Application © 2012 IBM Corporation
  • 8. Anatomy of a Java Object ■ A Java Object consists of: – Object data (fields) • boolean, byte, char, short, int, float, long, double and object references – Object metadata • describes the Object data ■ Question: What is the size ratio of a Integer object, to an int value? (for a 32bit platform) (a) 1 : 1 (b) 1.5 : 1 (c) 2 : 1 (d) 3: 1 ■ Answer is option (e) 4 : 1 !! 8 From Java Code to Java Heap: Understanding the Memory Usage of Your Application © 2012 IBM Corporation
  • 9. Object Field Sizes Field Type Field size/bits 32bit Process 64bit Process Object Array Object Array boolean 32 8 32 8 byte 32 8 32 8 char 32 16 32 16 short 32 16 32 16 int 32 32 32 32 float 32 32 32 32 long 64 64 64 64 double 64 64 64 64 Objects 32 32 64* 64 *32bits if Compressed References / Compressed Oops enabled 9 From Java Code to Java Heap: Understanding the Memory Usage of Your Application © 2012 IBM Corporation
  • 10. Anatomy of a Java Object ■ Object Metadata: 3 slots of data (4 for arrays) – Class: pointer to class information – Flags: shape, hash code, etc – Lock: flatlock or pointer to inflated monitor – Size: the length of the array (arrays only) Size/Bits 0 32 64 96 128 160 192 224 256 288 320 Class pointer Flags Locks int Java Object Class pointer Flags Locks Size int Array Object ■ Additionally, all Objects are 8 byte aligned (16 byte for CompressedOops with large heaps) 10 From Java Code to Java Heap: Understanding the Memory Usage of Your Application © 2012 IBM Corporation
  • 11. Anatomy of a 64bit Java Object ■ Object Metadata: 3 slots of data (4 for arrays) – Class: pointer to class information – Flags: shape, hash code, etc – Lock: flatlock or pointer to inflated monitor – Size: the length of the array (arrays only) Size/Bits 0 32 64 96 128 160 192 224 256 288 320 Class pointer pointer Class Flags Locks Flags int Locks int Java Object Class pointer pointer Class Flags Locks Flags Size int Locks Size int Array Object ■ Size ratio of an Integer object to an int value becomes 9:1 !! 11 From Java Code to Java Heap: Understanding the Memory Usage of Your Application © 2012 IBM Corporation
  • 12. Compressed References and CompressedOOPs ■ Migrating an application from 32bit to 64bit Java increases memory usage: – Java heap usage increases by ~70% – “Native” heap usage increases by ~90% ■ Compressed References / Compressed Ordinary Object Pointers – Use bit shifted, relative addressing for 64bit Java heaps – Object metadata and Objects references become 32bits ■ Using compressed technologies does remove Java heap usage increase ■ Using compressed technologies does not remove “native” heap usage increase 12 From Java Code to Java Heap: Understanding the Memory Usage of Your Application © 2012 IBM Corporation
  • 13. Allocating (slightly) more complex objects ■ Good object orientated design encourages encapsulation and delegation ■ Simple example: java.lang.String containing “MyString”: Size/Bits 0 32 64 96 128 160 192 224 256 288 320 Class pointer Flags Locks hash count offset value java.lang.String Class pointer Flags Locks Size char char char char char char char char char[] ■ 128 bits of char data, stored in 480 bits of memory, size ratio of 3.75 : 1 – Maximum overhead would be 24:1 for a single character! 13 From Java Code to Java Heap: Understanding the Memory Usage of Your Application © 2012 IBM Corporation
  • 14. Java Collections ■ Each Java Collection has a different level of function, and memory overhead HashSet Increasing Function Increasing Size HashMap Hashtable LinkedList ArrayList ■ Using the wrong type of collection can incur significant additional memory overhead 14 From Java Code to Java Heap: Understanding the Memory Usage of Your Application © 2012 IBM Corporation
  • 15. HashSet ■ Implementation of the Set interface – “A collection that contains no duplicate elements. More formally, sets contain no pair of elements e1 and e2 such that e1.equals(e2), and at most one null element. As implied by its name, this interface models the mathematical set abstraction. “ • Java Platform SE 6 API doc ■ Implementation is a wrapper around a HashMap: ■ Default capacity for HashSet is 16 ■ Empty size is 144 bytes ■ Additional 16 bytes / 128 bits overhead for wrappering over HashMap 15 From Java Code to Java Heap: Understanding the Memory Usage of Your Application © 2012 IBM Corporation
  • 16. HashMap ■ Implementation of the Map interface: – “An object that maps keys to values. A map cannot contain duplicate keys; each key can map to at most one value.“ • Java Platform SE 6 API doc ■ Implementation is an array of HashMap$Entry objects: ■ Default capacity is 16 entries ■ Empty size is 128 bytes ■ Overhead is 48 bytes for HashMap, plus (16 + (entries * 4bytes)) for array – Plus overhead of HashMap$Entry objects 16 From Java Code to Java Heap: Understanding the Memory Usage of Your Application © 2012 IBM Corporation
  • 17. HashMap$Entry ■ Each HashMap$Entry contains: – int KeyHash – Object next – Object key – Object value ■ Additional 32bytes per key ↔ value entry ■ Overhead of HashMap is therefore: – 48 bytes, plus 36 bytes per entry ■ For a 10,000 entry HashMap, the overhead is ~360K 17 From Java Code to Java Heap: Understanding the Memory Usage of Your Application © 2012 IBM Corporation
  • 18. Hashtable ■ Implementation of the Map interface: – “This class implements a hashtable, which maps keys to values. Any non-null object can be used as a key or as a value.“ • Java Platform SE 6 API doc ■ Implementation is an array of Hashtable$Entry objects: ■ Default capacity is 11 entries ■ Empty size is 104 bytes ■ Overhead is 40 bytes for Hashtable, plus (16 + (entries * 4bytes)) for array – Plus overhead of Hashtable$Entry objects 18 From Java Code to Java Heap: Understanding the Memory Usage of Your Application © 2012 IBM Corporation
  • 19. Hashtable$Entry ■ Each Hashtable$Entry contains: – int KeyHash – Object next – Object key – Object value ■ Additional 32bytes per key ↔ value entry ■ Overhead of Hashtable is therefore: – 40 bytes, plus 36 bytes per entry ■ For a 10,000 entry Hashtable, the overhead is ~360K 19 From Java Code to Java Heap: Understanding the Memory Usage of Your Application © 2012 IBM Corporation
  • 20. LinkedList ■ Linked list implementation of the List interface: – “An ordered collection (also known as a sequence). The user of this interface has precise control over where in the list each element is inserted. The user can access elements by their integer index (position in the list), and search for elements in the list. – Unlike sets, lists typically allow duplicate elements. “ • Java Platform SE 6 API doc ■ Implementation is a linked list of LinkedList$Entry objects (or LinkedList$Link): ■ Default capacity is 1 entry ■ Empty size is 48 bytes ■ Overhead is 24 bytes for LinkedList, plus overhead of LinkedList$Entry/Link objects 20 From Java Code to Java Heap: Understanding the Memory Usage of Your Application © 2012 IBM Corporation
  • 21. LinkedList$Entry / Link ■ Each LinkedList$Entry contains: – Object previous – Object next – Object entry ■ Additional 24bytes per entry ■ Overhead of LinkedList is therefore: – 24 bytes, plus 24 bytes per entry ■ For a 10,000 entry LinkedList, the overhead is ~240K 21 From Java Code to Java Heap: Understanding the Memory Usage of Your Application © 2012 IBM Corporation
  • 22. ArrayList ■ A resizeable array instance of the List interface: – “An ordered collection (also known as a sequence). The user of this interface has precise control over where in the list each element is inserted. The user can access elements by their integer index (position in the list), and search for elements in the list. – Unlike sets, lists typically allow duplicate elements. “ • Java Platform SE 6 API doc ■ Implementation is an array of Object: ■ Default capacity is 10 entries ■ Empty size is 88 bytes ■ Overhead is 32bytes for ArrayList, plus (16 + (entries * 4bytes)) for array ■ For a 10,000 entry ArrayList, the overhead is ~40K 22 From Java Code to Java Heap: Understanding the Memory Usage of Your Application © 2012 IBM Corporation
  • 23. Other types of “Collections” ■ StringBuffers can be considered to be a type of collection – “A thread-safe, mutable sequence of characters... .... – Every string buffer has a capacity. As long as the length of the character sequence contained in the string buffer does not exceed the capacity, it is not necessary to allocate a new internal buffer array. If the internal buffer overflows, it is automatically made larger.” • Java Platform SE 6 API doc ■ Implementation is an array of char ■ Default capacity is 16 characters ■ Empty size is 72 bytes ■ Overhead is just 24bytes for StringBuffer 23 From Java Code to Java Heap: Understanding the Memory Usage of Your Application © 2012 IBM Corporation
  • 24. Empty space in collections ■ Collections that contain empty space introduce additional overhead – Low “Fill Ratio” ■ Default collection size may not be appropriate for the amount of data being held 0 32 64 96 128 160 192 224 256 288 320 352 384 416 448 480 512 544 576 608 640 Class Flags Locks count value java.lang.StringBuffer Class Flags Locks Size charcharcharcharcharcharcharchar charcharcharcharcharcharcharchar M Y S T R I N G char[] ■ StringBuffer default of 16 is inappropriate to hold a 9 character string – 7 additional entries in char[] – 112 byte additional overhead 24 From Java Code to Java Heap: Understanding the Memory Usage of Your Application © 2012 IBM Corporation
  • 25. Expansion of collections ■ When collections hit the limit of their capacity, they expand – Greatly increases capacity – Greatly reduces “fill ratio” ■ Introduces additional collection overhead: 0 32 64 96 128 160 192 224 256 288 320 352 384 416 448 480 512 544 576 608 640 Class Flags Locks count value java.lang.StringBuffer Class Flags Locks Size charcharcharcharcharcharcharchar charcharcharcharcharcharcharcharcharcharcharcharcharcharchar charcharcharcharcharcharcharchar M Y S T R I N G O F T E X T char[] ■ Additional 16 char[] entries to hold single extra character – 240 byte additional overhead 25 From Java Code to Java Heap: Understanding the Memory Usage of Your Application © 2012 IBM Corporation
  • 26. Collections Summary Collection Default Empty Size 10K Entry Expansion Capacity Overhead Algorithm HashSet 16 144 360K double size HashMap 16 128 360K double size Hashtable 11 104 360K double size + 1 LinkedList 1 48 240K single entries ArrayList 10 88 40K size + 50% StringBuffer 16 72 24 double size 26 From Java Code to Java Heap: Understanding the Memory Usage of Your Application © 2012 IBM Corporation
  • 27. Collections Summary ■ Collections exist in large numbers in many Java applications ■ Example: IBM WebSphere Application Server running PlantsByWebSphere – When running a 5 user test load, and using 206MB of Java heap: HashTable 262,234 instances, 26.5MB of Java heap WeakHashMap 19,562 instances 2.6MB of Java heap HashMap 10,600 instances 2.3MB of Java heap ArrayList 9,530 instances 0.3MB of Java heap HashSet 1,551 instances 1.0MB of Java heap Vector 1,271 instances 0.04MB of Java heap LinkedList 1,148 instances 0.1MB of Java heap TreeMap 299 instances 0.03MB of Java heap 306,195 32.9MB ■ 16% of the Java heap used just for the collection objects !! 27 From Java Code to Java Heap: Understanding the Memory Usage of Your Application © 2012 IBM Corporation
  • 28. Analyzing your Collections ■ Eclipse Memory Analyzer Tool (MAT) provides Collection analysis: 28 From Java Code to Java Heap: Understanding the Memory Usage of Your Application © 2012 IBM Corporation
  • 29. Analyzing your DirectByteBuffers ■ IBM Extensions for Memory Analyzer (IEMA) provides DirectByteBuffer analysis: 29 From Java Code to Java Heap: Understanding the Memory Usage of Your Application © 2012 IBM Corporation
  • 30. Summary ■ There is significant overhead to your data! – Some of which is on the “native” heap ■ Applications often have: – The wrong collection types in use – Empty or sparsely populated collections ■ Careful use of: – Data structure layout – Collection type selection – Collection type default sizing Can improve your memory efficiency ■ Eclipse Memory Analyzer Tool can identify inefficiencies in your application – As well as show you the wider memory usage for code 30 From Java Code to Java Heap: Understanding the Memory Usage of Your Application © 2012 IBM Corporation
  • 31. Read the Article: From Java Code to Java Heap on IBM developerWorks: http://www.ibm.com/developerworks/java/library/j-codetoheap/index.html 31 From Java Code to Java Heap: Understanding the Memory Usage of Your Application © 2012 IBM Corporation
  • 32. References ■ Get Products and Technologies: – IBM Monitoring and Diagnostic Tools for Java: • https://www.ibm.com/developerworks/java/jdk/tools/ – Eclipse Memory Analyzer Tool: • http://eclipse.org/mat/downloads.php ■ Learn: – Debugging from Dumps: • http://www.ibm.com/developerworks/java/library/j-memoryanalyzer/index.html – Why the Memory Analyzer (with IBM Extensions) isn't just for memory leaks anymore: • http://www.ibm.com/developerworks/websphere/techjournal/1103_supauth/1103_sup auth.html ■ Discuss: – IBM on Troubleshooting Java Applications Blog: • https://www.ibm.com/developerworks/mydeveloperworks/blogs/troubleshootingjava/ – IBM Java Runtimes and SDKs Forum: • http://www.ibm.com/developerworks/forums/forum.jspa?forumID=367&start=0 32 From Java Code to Java Heap: Understanding the Memory Usage of Your Application © 2012 IBM Corporation
  • 33. Copyright and Trademarks © IBM Corporation 2012. All Rights Reserved. IBM, the IBM logo, and ibm.com are trademarks or registered trademarks of International Business Machines Corp., and registered in many jurisdictions worldwide. Other product and service names might be trademarks of IBM or other companies. A current list of IBM trademarks is available on the Web – see the IBM “Copyright and trademark information” page at URL: www.ibm.com/legal/copytrade.shtml 33 From Java Code to Java Heap: Understanding the Memory Usage of Your Application © 2012 IBM Corporation