SlideShare une entreprise Scribd logo
1  sur  52
Télécharger pour lire hors ligne
© 2013 IBM Corporation
Chris Bailey – IBM Java Service Architect
26th
September 2013
Memory-Efficient Java Code
Write low overhead application code
Document number
© 2013 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
© 2013 IBM Corporation3
Introduction to the speaker
 13 years experience developing and deploying Java SDKs
 Recent work focus:
– Java applications in the cloud
– 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/in/chrisbaileyibm
– http://www.slideshare.net/cnbailey/
© 2013 IBM Corporation4
Goals of this talk
 Understand the memory usage of Java code
 Minimize the creation of new objects
 Choose the right collection types
 Analyze your application for memory inefficiencies
© 2013 IBM Corporation5
Java Memory Usage
© 2013 IBM Corporation6
Anatomy of a Java Object
 A: Option 5: 128bits (4:1)
public static void main(String[] args) {
Integer myInteger = new Integer(10);
}
 Q: An int value is 32bits. How big is an Integer object? (on 32bit)
– Option 1: 32 bits (1:1)
– Option 2: 48 bits (1.5:1)
– Option 3: 64 bits (2:1)
– Option 4: 96 bits (3:1)
© 2013 IBM Corporation7
Anatomy of a Java Object
 Typical Object Metadata:
0 32 64 96 128 160 192 224 256 288 320
Class pointer Flags Locks int: 10
Class pointer Flags Locks int: 10Size
Java Object
Array Object
public static void main(String[] args) {
Integer myInteger = new Integer(10);
}
– 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)
© 2013 IBM Corporation8
Anatomy of a Java Object: 64bit
0 32 64 96 128 160 192 224 256 288 320
Java Object
Array Object
public static void main(String[] args) {
Integer myInteger = new Integer(10);
}
Class pointer Flags Locks intClass pointer Flags Locks int, eg. 10
Class pointer Flags Locks intSizeClass pointer Flags Locks int, eg. 10Size
 Size ratio of an Integer object to an int value becomes 9:1 !!
 Typical Object Metadata:
– 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)
© 2013 IBM Corporation9
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
© 2013 IBM Corporation10
Anatomy of a Java Object: 64bit with Compressed Refs/OOPs
0 32 64 96 128 160 192 224 256 288 320
Java Object
Array Object
public static void main(String[] args) {
Integer myInteger = new Integer(10);
}
Class pointer Flags Locks intClass pointer Flags Locks int, eg. 10
Class pointer Flags Locks intSizeClass pointer Flags Locks int, eg. 10Size
 Typical Object Metadata:
– 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)
© 2013 IBM Corporation11
Object Field Sizes
Field Type Field size/bits
32bit 64bit Compressed
Object Array Object Array Object Array
boolean 32 8 32 8 32 8
byte 32 8 32 8 32 8
char 32 16 32 16 32 16
short 32 16 32 16 32 16
int 32 32 32 32 32 32
float 32 32 32 32 32 32
long 64 64 64 64 64 64
double 64 64 64 64 64 64
Objects 32 32 64 64 32 32
© 2013 IBM Corporation12
Allocating (slightly) more complex objects
 Good object orientated design encourages encapsulation and delegation
 Example: java.lang.String encapsulates a character array:
Class pointer Flags Locks hash
Class pointer Flags Locks Size
java.lang.Stringcount offset value
char
M
char
Y
char
S
char
T
char
R
char
I
char
N
char
G char[]
public static void main(String[] args) {
String myString = new String("MyString");
}
0 32 64 96 128 160 192 224 256 288 320
 128 bits of char data, stored in 480 bits of memory, size ratio of x3.75
– Maximum overhead would be x24 for a single character!
© 2013 IBM Corporation13
Summary
 Objects are (much) larger than the data you store in them
– Allows Java to do memory management
– Allows Java to provide synchronization on your data
– Allows tools to analyze and visualize application memory
 32bit vs 64bit has an effect on your memory usage
– Use CompressedOOPs/Refs to mitigate additional Object overhead
 More recent Java VMs also have other memory improvements
– Lazy lock word allocation, etc
© 2013 IBM Corporation14
Object Allocation / Reclamation
© 2013 IBM Corporation15
Temporary Objects
 Most Objects created by an application are “temporary”
– Used as part of a calculation, transform, business transaction, etc
 Temporary Objects need to be allocated and reclaimed
– Memory management carried out by the Garbage Collector
 Garbage Collection is a tax on your application performance
– Time spent garbage collecting is time the application isn't running
– Typically up to 10% of overhead
© 2013 IBM Corporation16
Allocated 0
Reclaimed 0
Allocated 2
Reclaimed 0
Allocated 4
Reclaimed 0
Allocated 6
Reclaimed 0
Allocated 8
Reclaimed 0
Allocated 8
Reclaimed 2
Allocated 8
Reclaimed 4
Allocated 8
Reclaimed 6
String Concatenation
 Concatenation of Strings using the '+' operator equates to:
String s1 = “String1”;
String s2 = “String2”;
String s3 = s1 + s2;
String s3 = new StringBuilder(String.valueOf(s1)).append(s2).toString()
String s1
char[] “String 1”
String s2
char[] “String 2”
char[]
String s3
char[]
StringBuilderchar[] “String 1”
char[] “String 2”
© 2013 IBM Corporation17
String Interning and String Literals
 Java optimizes String usage by interning Strings
– Stores unique strings in a data collection
 Prevents the need to allocate Strings if they are already in the data collection
– No need to allocate s1 and s2
– They become references into the data collection
– The intern String cache reduces are allocations to 2, and our reclamations to 1.
 String literals are automatically interned by the JVM
 Concatenation of final String literals is done at compile time
© 2013 IBM Corporation18
Summary
 Time is spent by garbage collection removing unwanted data and Objects
– Performance tax: Time spent running GC and not running your application
 Allocation and reclamation can be reduced using caches
– The data we need already exists
 Using caches can actually reduce overall memory usage
– Where data can be shared rather than copied
© 2013 IBM Corporation19
Object Caching
© 2013 IBM Corporation20
Java Collections
 Each Java Collection has a different level of function, and memory overhead
 Using the wrong type of collection can incur significant additional memory overhead
IncreasingFunction
java.util.HashSet
java.util.HashMap
java.util.Hashtable
java.util.LinkedList
java.util.ArrayList
IncreasingSize
© 2013 IBM Corporation21
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.“
 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
public static void main(String[] args) {
HashMap myHashMap = new HashMap();
}
© 2013 IBM Corporation22
HashMap Structure
HashMap
array[16]
© 2013 IBM Corporation23
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
© 2013 IBM Corporation24
HashMap Structure
HashMap
array[16]
HashMap$Entry
Object key
Object value
HashMap$Entry
Object key
Object value
HashMap$Entry
Object key
Object value
HashMap$Entry
Object key
Object value
HashMap$Entry
Object key
Object value
© 2013 IBM Corporation25
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. “
 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
public static void main(String[] args) {
LinkedList myLinkedList = new LinkedList();
}
© 2013 IBM Corporation26
LinkedList Structure
LinkedList
© 2013 IBM Corporation27
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
© 2013 IBM Corporation28
LinkedList Structure
LinkedList
LinkedList$Entry
Object value
LinkedList$Entry
Object value
LinkedList$Entry
Object value
LinkedList$Entry
Object value
© 2013 IBM Corporation29
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. “
 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
public static void main(String[] args) {
ArrayList myArrayList = new ArrayList();
}
© 2013 IBM Corporation30
ArrayList Structure
ArrayList
value value value value value value value value value value
© 2013 IBM Corporation31
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.”
 Implementation is an array of char
 Default capacity is 16 characters
 Empty size is 72 bytes
 Overhead is just 24bytes for StringBuffer
public static void main(String[] args) {
StringBuffer myStringBuffer = new StringBuffer();
}
© 2013 IBM Corporation32
StringBuffer Structure
StringBuffer
char char char char char char char char char char char char char char char char
© 2013 IBM Corporation33
Collections Summary
Collection Default Capacity Empty Size 10K Overhead
HashSet 16 144 360K
HashMap 16 128 360K
Hashtable 11 104 360K
LinkedList 1 48 240K
ArrayList 10 88 40K
StringBuffer 16 72 24
© 2013 IBM Corporation34
Hash* collections vs others
 Hash* collections are much larger
– x9 the size of an ArrayList
 Additional size helps search/insert/delete performance
– Constant for Hash collections
– Linear for Array collections
• If there is no other index
 Using the larger collection may be the right thing to do
– Important to know it is the right thing to do!
© 2013 IBM Corporation35
Empty space in collections
 Collections that contain empty space introduce additional overhead
 Default collection size may not be appropriate for the amount of data being held
java.lang.StringBuffer
char[]
0 32 64 96 128 160 192 224 256 288 320
Class Flags Locks count
Class Flags Locks charSize
value
charcharcharcharcharcharcharcharcharcharcharcharcharcharcharM Y S T R I N G
352 384 416 448 480 512 544 576 608 640
 StringBuffer default of 16 is inappropriate to hold a 9 character string
– 7 additional entries in char[]
– 112 byte additional overhead
public static void main(String[] args) {
StringBuffer myStringBuffer = new StringBuffer(“MyString”);
}
© 2013 IBM Corporation36
Expansion of collections
 When collections hit the limit of their capacity, they expand
– Greatly increases capacity
– Greatly reduces “fill ratio”
 Introduces additional collection overhead:
java.lang.StringBuffer
char[]
0 32 64 96 128 160 192 224 256 288 320
Class Flags Locks count
Class Flags Locks charSize
value
charcharcharcharcharcharcharcharcharcharcharcharcharcharcharcharcharcharcharcharcharcharcharcharcharcharcharcharcharcharM Y S T R I N G O F T E X T
352 384 416 448 480 512 544 576 608 640
 Additional 16 char[] entries to hold single extra character
– 240 byte additional overhead
© 2013 IBM Corporation37
Collections Summary
Collection Default Capacity Empty Size 10K Overhead Expansion
HashSet 16 144 360K x2
HashMap 16 128 360K x2
Hashtable 11 104 360K x2 + 1
LinkedList 1 48 240K +1
ArrayList 10 88 40K x1.5
StringBuffer 16 72 24 x2
© 2013 IBM Corporation38
Conclusions
 There is a memory footprint vs performance trade-off
 Hash* collections are much larger, but have better search/insert/delete performance
– x9 the size of an ArrayList
– Constant access times vs linear increase with size.
 Large collections avoid resizing, but increase memory overhead
– Collections expand by reallocation
– Collections do not automatically shrink
• Can be achieved via manual reallocation and copy
© 2013 IBM Corporation39
Application Analysis
© 2013 IBM Corporation40
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:
 16% of the Java heap used just for the collection objects !!
HashTable 262,234 instances, 26.5MB of Java heap
WeakHashMap 19,562 instances 12.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 42.9MB
© 2013 IBM Corporation41
Analyzing your Collections
 Eclipse Memory Analyzer Tool (MAT) provides Collection analysis:
© 2013 IBM Corporation42
Analyzing your Collections
 Can select a specific Collection (java.util.Hashtable) or any
© 2013 IBM Corporation43
Analyzing your Collections
 Shows 127,016 empty java.util.Hashtable instances!
© 2013 IBM Corporation44
Analyzing your Collections
 You can “List objects” to see what they are
© 2013 IBM Corporation45
Analyzing your Collections
 java.util.Hashtable objects being used to store session data!
© 2013 IBM Corporation46
Collection Analysis for PlantsByWebSphere Example
 Over 50% of collections are empty in our example
Collection Number Empty % Empty
Hashtable 262,234 127,016 48.8
WeakHashMap 19,562 19,456 99.5
HashMap 10,600 7,599 71.7
ArrayList 9,530 4,588 48.1
HashSet 1,551 866 55.8
Vector 1,271 622 48.9
Total 304,748 160,156 52.6
© 2013 IBM Corporation47
Improvements in the JDK: WeakHashMap
 12.5MB of memory being used for 19,456 empty instances of WeakHashMap
 560 bytes per instance used for java.lang.ref.ReferenceQueue
– ReferenceQueue only required is there are elements in the WeakHashMap
 Lazy allocation of ReferenceQueue saves 10.9MB in our example
WeakHashMap 19,562 19,456 99.5
© 2013 IBM Corporation48
Techniques for minimizing memory
 Lazy allocation of collections
– Don't create a collection until you have something to put into it
 Don't create collections for a single Object!
– Just store the Object itself
 Size collections correctly
– If only 2 entries will be stored, create with size 2:
HashMap myHashMap = new HashMap(2);
 Avoid expansion of large collections due to x2 algorithm
– 32MB used to store 17MB of data
 Collections do not shrink once expanded
– May need to reallocate if collection uses drops significantly
© 2013 IBM Corporation49
Summary
 There is significant overhead to your data!
 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
© 2013 IBM Corporation50
http://ibm.co/JavaOne2013
© 2013 IBM Corporation51
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
© 2013 IBM Corporation52
Copyright and Trademarks
© IBM Corporation 2013. 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

Contenu connexe

Tendances

The Apache Spark File Format Ecosystem
The Apache Spark File Format EcosystemThe Apache Spark File Format Ecosystem
The Apache Spark File Format EcosystemDatabricks
 
Scalable Monitoring Using Prometheus with Apache Spark Clusters with Diane F...
 Scalable Monitoring Using Prometheus with Apache Spark Clusters with Diane F... Scalable Monitoring Using Prometheus with Apache Spark Clusters with Diane F...
Scalable Monitoring Using Prometheus with Apache Spark Clusters with Diane F...Databricks
 
Parquet Hadoop Summit 2013
Parquet Hadoop Summit 2013Parquet Hadoop Summit 2013
Parquet Hadoop Summit 2013Julien Le Dem
 
Introduction to Apache Flink - Fast and reliable big data processing
Introduction to Apache Flink - Fast and reliable big data processingIntroduction to Apache Flink - Fast and reliable big data processing
Introduction to Apache Flink - Fast and reliable big data processingTill Rohrmann
 
Apache Spark in Depth: Core Concepts, Architecture & Internals
Apache Spark in Depth: Core Concepts, Architecture & InternalsApache Spark in Depth: Core Concepts, Architecture & Internals
Apache Spark in Depth: Core Concepts, Architecture & InternalsAnton Kirillov
 
Introduction to Apache ZooKeeper
Introduction to Apache ZooKeeperIntroduction to Apache ZooKeeper
Introduction to Apache ZooKeeperSaurav Haloi
 
Apache kafka 모니터링을 위한 Metrics 이해 및 최적화 방안
Apache kafka 모니터링을 위한 Metrics 이해 및 최적화 방안Apache kafka 모니터링을 위한 Metrics 이해 및 최적화 방안
Apache kafka 모니터링을 위한 Metrics 이해 및 최적화 방안SANG WON PARK
 
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
 
A Thorough Comparison of Delta Lake, Iceberg and Hudi
A Thorough Comparison of Delta Lake, Iceberg and HudiA Thorough Comparison of Delta Lake, Iceberg and Hudi
A Thorough Comparison of Delta Lake, Iceberg and HudiDatabricks
 
Efficient Data Storage for Analytics with Apache Parquet 2.0
Efficient Data Storage for Analytics with Apache Parquet 2.0Efficient Data Storage for Analytics with Apache Parquet 2.0
Efficient Data Storage for Analytics with Apache Parquet 2.0Cloudera, Inc.
 
Evening out the uneven: dealing with skew in Flink
Evening out the uneven: dealing with skew in FlinkEvening out the uneven: dealing with skew in Flink
Evening out the uneven: dealing with skew in FlinkFlink Forward
 
Building Robust ETL Pipelines with Apache Spark
Building Robust ETL Pipelines with Apache SparkBuilding Robust ETL Pipelines with Apache Spark
Building Robust ETL Pipelines with Apache SparkDatabricks
 
Apache Flink internals
Apache Flink internalsApache Flink internals
Apache Flink internalsKostas Tzoumas
 
Apache Tez: Accelerating Hadoop Query Processing
Apache Tez: Accelerating Hadoop Query Processing Apache Tez: Accelerating Hadoop Query Processing
Apache Tez: Accelerating Hadoop Query Processing DataWorks Summit
 
Performant Streaming in Production: Preventing Common Pitfalls when Productio...
Performant Streaming in Production: Preventing Common Pitfalls when Productio...Performant Streaming in Production: Preventing Common Pitfalls when Productio...
Performant Streaming in Production: Preventing Common Pitfalls when Productio...Databricks
 
Introduction to ML with Apache Spark MLlib
Introduction to ML with Apache Spark MLlibIntroduction to ML with Apache Spark MLlib
Introduction to ML with Apache Spark MLlibTaras Matyashovsky
 

Tendances (20)

The Apache Spark File Format Ecosystem
The Apache Spark File Format EcosystemThe Apache Spark File Format Ecosystem
The Apache Spark File Format Ecosystem
 
Scalable Monitoring Using Prometheus with Apache Spark Clusters with Diane F...
 Scalable Monitoring Using Prometheus with Apache Spark Clusters with Diane F... Scalable Monitoring Using Prometheus with Apache Spark Clusters with Diane F...
Scalable Monitoring Using Prometheus with Apache Spark Clusters with Diane F...
 
Rest API
Rest APIRest API
Rest API
 
Apache Kafka Best Practices
Apache Kafka Best PracticesApache Kafka Best Practices
Apache Kafka Best Practices
 
Parquet Hadoop Summit 2013
Parquet Hadoop Summit 2013Parquet Hadoop Summit 2013
Parquet Hadoop Summit 2013
 
Introduction to Apache Flink - Fast and reliable big data processing
Introduction to Apache Flink - Fast and reliable big data processingIntroduction to Apache Flink - Fast and reliable big data processing
Introduction to Apache Flink - Fast and reliable big data processing
 
Apache Spark in Depth: Core Concepts, Architecture & Internals
Apache Spark in Depth: Core Concepts, Architecture & InternalsApache Spark in Depth: Core Concepts, Architecture & Internals
Apache Spark in Depth: Core Concepts, Architecture & Internals
 
Introduction to Apache ZooKeeper
Introduction to Apache ZooKeeperIntroduction to Apache ZooKeeper
Introduction to Apache ZooKeeper
 
Apache kafka 모니터링을 위한 Metrics 이해 및 최적화 방안
Apache kafka 모니터링을 위한 Metrics 이해 및 최적화 방안Apache kafka 모니터링을 위한 Metrics 이해 및 최적화 방안
Apache kafka 모니터링을 위한 Metrics 이해 및 최적화 방안
 
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
 
A Thorough Comparison of Delta Lake, Iceberg and Hudi
A Thorough Comparison of Delta Lake, Iceberg and HudiA Thorough Comparison of Delta Lake, Iceberg and Hudi
A Thorough Comparison of Delta Lake, Iceberg and Hudi
 
Efficient Data Storage for Analytics with Apache Parquet 2.0
Efficient Data Storage for Analytics with Apache Parquet 2.0Efficient Data Storage for Analytics with Apache Parquet 2.0
Efficient Data Storage for Analytics with Apache Parquet 2.0
 
Evening out the uneven: dealing with skew in Flink
Evening out the uneven: dealing with skew in FlinkEvening out the uneven: dealing with skew in Flink
Evening out the uneven: dealing with skew in Flink
 
ELK Stack
ELK StackELK Stack
ELK Stack
 
Spark SQL
Spark SQLSpark SQL
Spark SQL
 
Building Robust ETL Pipelines with Apache Spark
Building Robust ETL Pipelines with Apache SparkBuilding Robust ETL Pipelines with Apache Spark
Building Robust ETL Pipelines with Apache Spark
 
Apache Flink internals
Apache Flink internalsApache Flink internals
Apache Flink internals
 
Apache Tez: Accelerating Hadoop Query Processing
Apache Tez: Accelerating Hadoop Query Processing Apache Tez: Accelerating Hadoop Query Processing
Apache Tez: Accelerating Hadoop Query Processing
 
Performant Streaming in Production: Preventing Common Pitfalls when Productio...
Performant Streaming in Production: Preventing Common Pitfalls when Productio...Performant Streaming in Production: Preventing Common Pitfalls when Productio...
Performant Streaming in Production: Preventing Common Pitfalls when Productio...
 
Introduction to ML with Apache Spark MLlib
Introduction to ML with Apache Spark MLlibIntroduction to ML with Apache Spark MLlib
Introduction to ML with Apache Spark MLlib
 

Similaire à JavaOne 2013: Memory Efficient Java

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
 
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
 
Memory efficient programming
Memory efficient programmingMemory efficient programming
Memory efficient programmingindikaMaligaspe
 
Using Pluggable Apache Spark SQL Filters to Help GridPocket Users Keep Up wit...
Using Pluggable Apache Spark SQL Filters to Help GridPocket Users Keep Up wit...Using Pluggable Apache Spark SQL Filters to Help GridPocket Users Keep Up wit...
Using Pluggable Apache Spark SQL Filters to Help GridPocket Users Keep Up wit...Spark Summit
 
Mongo db Quick Guide
Mongo db Quick GuideMongo db Quick Guide
Mongo db Quick GuideSourabh Sahu
 
C* for Deep Learning (Andrew Jefferson, Tracktable) | Cassandra Summit 2016
C* for Deep Learning (Andrew Jefferson, Tracktable) | Cassandra Summit 2016C* for Deep Learning (Andrew Jefferson, Tracktable) | Cassandra Summit 2016
C* for Deep Learning (Andrew Jefferson, Tracktable) | Cassandra Summit 2016DataStax
 
Running complex data queries in a distributed system
Running complex data queries in a distributed systemRunning complex data queries in a distributed system
Running complex data queries in a distributed systemArangoDB Database
 
IMC Summit 2016 Breakout - William Bain - Implementing Extensible Data Struct...
IMC Summit 2016 Breakout - William Bain - Implementing Extensible Data Struct...IMC Summit 2016 Breakout - William Bain - Implementing Extensible Data Struct...
IMC Summit 2016 Breakout - William Bain - Implementing Extensible Data Struct...In-Memory Computing Summit
 
Amazon Elasticsearch Service Deep Dive - AWS Online Tech Talks
Amazon Elasticsearch Service Deep Dive - AWS Online Tech TalksAmazon Elasticsearch Service Deep Dive - AWS Online Tech Talks
Amazon Elasticsearch Service Deep Dive - AWS Online Tech TalksAmazon Web Services
 
Mongodb in-anger-boston-rb-2011
Mongodb in-anger-boston-rb-2011Mongodb in-anger-boston-rb-2011
Mongodb in-anger-boston-rb-2011bostonrb
 
Myths of Big Partitions (Robert Stupp, DataStax) | Cassandra Summit 2016
Myths of Big Partitions (Robert Stupp, DataStax) | Cassandra Summit 2016Myths of Big Partitions (Robert Stupp, DataStax) | Cassandra Summit 2016
Myths of Big Partitions (Robert Stupp, DataStax) | Cassandra Summit 2016DataStax
 
IMPLEMENTATION OF DNA CRYPTOGRAPHY IN CLOUD COMPUTING AND.pptx
IMPLEMENTATION OF DNA CRYPTOGRAPHY IN CLOUD COMPUTING AND.pptxIMPLEMENTATION OF DNA CRYPTOGRAPHY IN CLOUD COMPUTING AND.pptx
IMPLEMENTATION OF DNA CRYPTOGRAPHY IN CLOUD COMPUTING AND.pptxDeepikaShivam
 
Eagle6 mongo dc revised
Eagle6 mongo dc revisedEagle6 mongo dc revised
Eagle6 mongo dc revisedMongoDB
 
Eagle6 Enterprise Situational Awareness
Eagle6 Enterprise Situational AwarenessEagle6 Enterprise Situational Awareness
Eagle6 Enterprise Situational AwarenessMongoDB
 
OrientDB for real & Web App development
OrientDB for real & Web App developmentOrientDB for real & Web App development
OrientDB for real & Web App developmentLuca Garulli
 
Airframe: Lightweight Building Blocks for Scala @ TD Tech Talk 2018-10-17
Airframe: Lightweight Building Blocks for Scala @ TD Tech Talk 2018-10-17Airframe: Lightweight Building Blocks for Scala @ TD Tech Talk 2018-10-17
Airframe: Lightweight Building Blocks for Scala @ TD Tech Talk 2018-10-17Taro L. Saito
 
housing price prediction ppt in artificial
housing price prediction ppt in artificialhousing price prediction ppt in artificial
housing price prediction ppt in artificialKrishPatel802536
 
Sperasoft‬ talks j point 2015
Sperasoft‬ talks j point 2015Sperasoft‬ talks j point 2015
Sperasoft‬ talks j point 2015Sperasoft
 

Similaire à JavaOne 2013: Memory Efficient Java (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...
 
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...
 
Memory efficient programming
Memory efficient programmingMemory efficient programming
Memory efficient programming
 
Using Pluggable Apache Spark SQL Filters to Help GridPocket Users Keep Up wit...
Using Pluggable Apache Spark SQL Filters to Help GridPocket Users Keep Up wit...Using Pluggable Apache Spark SQL Filters to Help GridPocket Users Keep Up wit...
Using Pluggable Apache Spark SQL Filters to Help GridPocket Users Keep Up wit...
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
Mongo db Quick Guide
Mongo db Quick GuideMongo db Quick Guide
Mongo db Quick Guide
 
C* for Deep Learning (Andrew Jefferson, Tracktable) | Cassandra Summit 2016
C* for Deep Learning (Andrew Jefferson, Tracktable) | Cassandra Summit 2016C* for Deep Learning (Andrew Jefferson, Tracktable) | Cassandra Summit 2016
C* for Deep Learning (Andrew Jefferson, Tracktable) | Cassandra Summit 2016
 
Running complex data queries in a distributed system
Running complex data queries in a distributed systemRunning complex data queries in a distributed system
Running complex data queries in a distributed system
 
IMC Summit 2016 Breakout - William Bain - Implementing Extensible Data Struct...
IMC Summit 2016 Breakout - William Bain - Implementing Extensible Data Struct...IMC Summit 2016 Breakout - William Bain - Implementing Extensible Data Struct...
IMC Summit 2016 Breakout - William Bain - Implementing Extensible Data Struct...
 
Amazon Elasticsearch Service Deep Dive - AWS Online Tech Talks
Amazon Elasticsearch Service Deep Dive - AWS Online Tech TalksAmazon Elasticsearch Service Deep Dive - AWS Online Tech Talks
Amazon Elasticsearch Service Deep Dive - AWS Online Tech Talks
 
Mongodb in-anger-boston-rb-2011
Mongodb in-anger-boston-rb-2011Mongodb in-anger-boston-rb-2011
Mongodb in-anger-boston-rb-2011
 
Myths of Big Partitions (Robert Stupp, DataStax) | Cassandra Summit 2016
Myths of Big Partitions (Robert Stupp, DataStax) | Cassandra Summit 2016Myths of Big Partitions (Robert Stupp, DataStax) | Cassandra Summit 2016
Myths of Big Partitions (Robert Stupp, DataStax) | Cassandra Summit 2016
 
IMPLEMENTATION OF DNA CRYPTOGRAPHY IN CLOUD COMPUTING AND.pptx
IMPLEMENTATION OF DNA CRYPTOGRAPHY IN CLOUD COMPUTING AND.pptxIMPLEMENTATION OF DNA CRYPTOGRAPHY IN CLOUD COMPUTING AND.pptx
IMPLEMENTATION OF DNA CRYPTOGRAPHY IN CLOUD COMPUTING AND.pptx
 
Eagle6 mongo dc revised
Eagle6 mongo dc revisedEagle6 mongo dc revised
Eagle6 mongo dc revised
 
Eagle6 Enterprise Situational Awareness
Eagle6 Enterprise Situational AwarenessEagle6 Enterprise Situational Awareness
Eagle6 Enterprise Situational Awareness
 
OrientDB for real & Web App development
OrientDB for real & Web App developmentOrientDB for real & Web App development
OrientDB for real & Web App development
 
Airframe: Lightweight Building Blocks for Scala @ TD Tech Talk 2018-10-17
Airframe: Lightweight Building Blocks for Scala @ TD Tech Talk 2018-10-17Airframe: Lightweight Building Blocks for Scala @ TD Tech Talk 2018-10-17
Airframe: Lightweight Building Blocks for Scala @ TD Tech Talk 2018-10-17
 
housing price prediction ppt in artificial
housing price prediction ppt in artificialhousing price prediction ppt in artificial
housing price prediction ppt in artificial
 
Sperasoft‬ talks j point 2015
Sperasoft‬ talks j point 2015Sperasoft‬ talks j point 2015
Sperasoft‬ talks j point 2015
 
Bids talk 9.18
Bids talk 9.18Bids talk 9.18
Bids talk 9.18
 

Plus de 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
 

Plus de 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
 

Dernier

Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 

Dernier (20)

Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 

JavaOne 2013: Memory Efficient Java

  • 1. © 2013 IBM Corporation Chris Bailey – IBM Java Service Architect 26th September 2013 Memory-Efficient Java Code Write low overhead application code Document number
  • 2. © 2013 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
  • 3. © 2013 IBM Corporation3 Introduction to the speaker  13 years experience developing and deploying Java SDKs  Recent work focus: – Java applications in the cloud – 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/in/chrisbaileyibm – http://www.slideshare.net/cnbailey/
  • 4. © 2013 IBM Corporation4 Goals of this talk  Understand the memory usage of Java code  Minimize the creation of new objects  Choose the right collection types  Analyze your application for memory inefficiencies
  • 5. © 2013 IBM Corporation5 Java Memory Usage
  • 6. © 2013 IBM Corporation6 Anatomy of a Java Object  A: Option 5: 128bits (4:1) public static void main(String[] args) { Integer myInteger = new Integer(10); }  Q: An int value is 32bits. How big is an Integer object? (on 32bit) – Option 1: 32 bits (1:1) – Option 2: 48 bits (1.5:1) – Option 3: 64 bits (2:1) – Option 4: 96 bits (3:1)
  • 7. © 2013 IBM Corporation7 Anatomy of a Java Object  Typical Object Metadata: 0 32 64 96 128 160 192 224 256 288 320 Class pointer Flags Locks int: 10 Class pointer Flags Locks int: 10Size Java Object Array Object public static void main(String[] args) { Integer myInteger = new Integer(10); } – 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)
  • 8. © 2013 IBM Corporation8 Anatomy of a Java Object: 64bit 0 32 64 96 128 160 192 224 256 288 320 Java Object Array Object public static void main(String[] args) { Integer myInteger = new Integer(10); } Class pointer Flags Locks intClass pointer Flags Locks int, eg. 10 Class pointer Flags Locks intSizeClass pointer Flags Locks int, eg. 10Size  Size ratio of an Integer object to an int value becomes 9:1 !!  Typical Object Metadata: – 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)
  • 9. © 2013 IBM Corporation9 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
  • 10. © 2013 IBM Corporation10 Anatomy of a Java Object: 64bit with Compressed Refs/OOPs 0 32 64 96 128 160 192 224 256 288 320 Java Object Array Object public static void main(String[] args) { Integer myInteger = new Integer(10); } Class pointer Flags Locks intClass pointer Flags Locks int, eg. 10 Class pointer Flags Locks intSizeClass pointer Flags Locks int, eg. 10Size  Typical Object Metadata: – 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)
  • 11. © 2013 IBM Corporation11 Object Field Sizes Field Type Field size/bits 32bit 64bit Compressed Object Array Object Array Object Array boolean 32 8 32 8 32 8 byte 32 8 32 8 32 8 char 32 16 32 16 32 16 short 32 16 32 16 32 16 int 32 32 32 32 32 32 float 32 32 32 32 32 32 long 64 64 64 64 64 64 double 64 64 64 64 64 64 Objects 32 32 64 64 32 32
  • 12. © 2013 IBM Corporation12 Allocating (slightly) more complex objects  Good object orientated design encourages encapsulation and delegation  Example: java.lang.String encapsulates a character array: Class pointer Flags Locks hash Class pointer Flags Locks Size java.lang.Stringcount offset value char M char Y char S char T char R char I char N char G char[] public static void main(String[] args) { String myString = new String("MyString"); } 0 32 64 96 128 160 192 224 256 288 320  128 bits of char data, stored in 480 bits of memory, size ratio of x3.75 – Maximum overhead would be x24 for a single character!
  • 13. © 2013 IBM Corporation13 Summary  Objects are (much) larger than the data you store in them – Allows Java to do memory management – Allows Java to provide synchronization on your data – Allows tools to analyze and visualize application memory  32bit vs 64bit has an effect on your memory usage – Use CompressedOOPs/Refs to mitigate additional Object overhead  More recent Java VMs also have other memory improvements – Lazy lock word allocation, etc
  • 14. © 2013 IBM Corporation14 Object Allocation / Reclamation
  • 15. © 2013 IBM Corporation15 Temporary Objects  Most Objects created by an application are “temporary” – Used as part of a calculation, transform, business transaction, etc  Temporary Objects need to be allocated and reclaimed – Memory management carried out by the Garbage Collector  Garbage Collection is a tax on your application performance – Time spent garbage collecting is time the application isn't running – Typically up to 10% of overhead
  • 16. © 2013 IBM Corporation16 Allocated 0 Reclaimed 0 Allocated 2 Reclaimed 0 Allocated 4 Reclaimed 0 Allocated 6 Reclaimed 0 Allocated 8 Reclaimed 0 Allocated 8 Reclaimed 2 Allocated 8 Reclaimed 4 Allocated 8 Reclaimed 6 String Concatenation  Concatenation of Strings using the '+' operator equates to: String s1 = “String1”; String s2 = “String2”; String s3 = s1 + s2; String s3 = new StringBuilder(String.valueOf(s1)).append(s2).toString() String s1 char[] “String 1” String s2 char[] “String 2” char[] String s3 char[] StringBuilderchar[] “String 1” char[] “String 2”
  • 17. © 2013 IBM Corporation17 String Interning and String Literals  Java optimizes String usage by interning Strings – Stores unique strings in a data collection  Prevents the need to allocate Strings if they are already in the data collection – No need to allocate s1 and s2 – They become references into the data collection – The intern String cache reduces are allocations to 2, and our reclamations to 1.  String literals are automatically interned by the JVM  Concatenation of final String literals is done at compile time
  • 18. © 2013 IBM Corporation18 Summary  Time is spent by garbage collection removing unwanted data and Objects – Performance tax: Time spent running GC and not running your application  Allocation and reclamation can be reduced using caches – The data we need already exists  Using caches can actually reduce overall memory usage – Where data can be shared rather than copied
  • 19. © 2013 IBM Corporation19 Object Caching
  • 20. © 2013 IBM Corporation20 Java Collections  Each Java Collection has a different level of function, and memory overhead  Using the wrong type of collection can incur significant additional memory overhead IncreasingFunction java.util.HashSet java.util.HashMap java.util.Hashtable java.util.LinkedList java.util.ArrayList IncreasingSize
  • 21. © 2013 IBM Corporation21 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.“  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 public static void main(String[] args) { HashMap myHashMap = new HashMap(); }
  • 22. © 2013 IBM Corporation22 HashMap Structure HashMap array[16]
  • 23. © 2013 IBM Corporation23 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
  • 24. © 2013 IBM Corporation24 HashMap Structure HashMap array[16] HashMap$Entry Object key Object value HashMap$Entry Object key Object value HashMap$Entry Object key Object value HashMap$Entry Object key Object value HashMap$Entry Object key Object value
  • 25. © 2013 IBM Corporation25 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. “  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 public static void main(String[] args) { LinkedList myLinkedList = new LinkedList(); }
  • 26. © 2013 IBM Corporation26 LinkedList Structure LinkedList
  • 27. © 2013 IBM Corporation27 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
  • 28. © 2013 IBM Corporation28 LinkedList Structure LinkedList LinkedList$Entry Object value LinkedList$Entry Object value LinkedList$Entry Object value LinkedList$Entry Object value
  • 29. © 2013 IBM Corporation29 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. “  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 public static void main(String[] args) { ArrayList myArrayList = new ArrayList(); }
  • 30. © 2013 IBM Corporation30 ArrayList Structure ArrayList value value value value value value value value value value
  • 31. © 2013 IBM Corporation31 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.”  Implementation is an array of char  Default capacity is 16 characters  Empty size is 72 bytes  Overhead is just 24bytes for StringBuffer public static void main(String[] args) { StringBuffer myStringBuffer = new StringBuffer(); }
  • 32. © 2013 IBM Corporation32 StringBuffer Structure StringBuffer char char char char char char char char char char char char char char char char
  • 33. © 2013 IBM Corporation33 Collections Summary Collection Default Capacity Empty Size 10K Overhead HashSet 16 144 360K HashMap 16 128 360K Hashtable 11 104 360K LinkedList 1 48 240K ArrayList 10 88 40K StringBuffer 16 72 24
  • 34. © 2013 IBM Corporation34 Hash* collections vs others  Hash* collections are much larger – x9 the size of an ArrayList  Additional size helps search/insert/delete performance – Constant for Hash collections – Linear for Array collections • If there is no other index  Using the larger collection may be the right thing to do – Important to know it is the right thing to do!
  • 35. © 2013 IBM Corporation35 Empty space in collections  Collections that contain empty space introduce additional overhead  Default collection size may not be appropriate for the amount of data being held java.lang.StringBuffer char[] 0 32 64 96 128 160 192 224 256 288 320 Class Flags Locks count Class Flags Locks charSize value charcharcharcharcharcharcharcharcharcharcharcharcharcharcharM Y S T R I N G 352 384 416 448 480 512 544 576 608 640  StringBuffer default of 16 is inappropriate to hold a 9 character string – 7 additional entries in char[] – 112 byte additional overhead public static void main(String[] args) { StringBuffer myStringBuffer = new StringBuffer(“MyString”); }
  • 36. © 2013 IBM Corporation36 Expansion of collections  When collections hit the limit of their capacity, they expand – Greatly increases capacity – Greatly reduces “fill ratio”  Introduces additional collection overhead: java.lang.StringBuffer char[] 0 32 64 96 128 160 192 224 256 288 320 Class Flags Locks count Class Flags Locks charSize value charcharcharcharcharcharcharcharcharcharcharcharcharcharcharcharcharcharcharcharcharcharcharcharcharcharcharcharcharcharM Y S T R I N G O F T E X T 352 384 416 448 480 512 544 576 608 640  Additional 16 char[] entries to hold single extra character – 240 byte additional overhead
  • 37. © 2013 IBM Corporation37 Collections Summary Collection Default Capacity Empty Size 10K Overhead Expansion HashSet 16 144 360K x2 HashMap 16 128 360K x2 Hashtable 11 104 360K x2 + 1 LinkedList 1 48 240K +1 ArrayList 10 88 40K x1.5 StringBuffer 16 72 24 x2
  • 38. © 2013 IBM Corporation38 Conclusions  There is a memory footprint vs performance trade-off  Hash* collections are much larger, but have better search/insert/delete performance – x9 the size of an ArrayList – Constant access times vs linear increase with size.  Large collections avoid resizing, but increase memory overhead – Collections expand by reallocation – Collections do not automatically shrink • Can be achieved via manual reallocation and copy
  • 39. © 2013 IBM Corporation39 Application Analysis
  • 40. © 2013 IBM Corporation40 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:  16% of the Java heap used just for the collection objects !! HashTable 262,234 instances, 26.5MB of Java heap WeakHashMap 19,562 instances 12.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 42.9MB
  • 41. © 2013 IBM Corporation41 Analyzing your Collections  Eclipse Memory Analyzer Tool (MAT) provides Collection analysis:
  • 42. © 2013 IBM Corporation42 Analyzing your Collections  Can select a specific Collection (java.util.Hashtable) or any
  • 43. © 2013 IBM Corporation43 Analyzing your Collections  Shows 127,016 empty java.util.Hashtable instances!
  • 44. © 2013 IBM Corporation44 Analyzing your Collections  You can “List objects” to see what they are
  • 45. © 2013 IBM Corporation45 Analyzing your Collections  java.util.Hashtable objects being used to store session data!
  • 46. © 2013 IBM Corporation46 Collection Analysis for PlantsByWebSphere Example  Over 50% of collections are empty in our example Collection Number Empty % Empty Hashtable 262,234 127,016 48.8 WeakHashMap 19,562 19,456 99.5 HashMap 10,600 7,599 71.7 ArrayList 9,530 4,588 48.1 HashSet 1,551 866 55.8 Vector 1,271 622 48.9 Total 304,748 160,156 52.6
  • 47. © 2013 IBM Corporation47 Improvements in the JDK: WeakHashMap  12.5MB of memory being used for 19,456 empty instances of WeakHashMap  560 bytes per instance used for java.lang.ref.ReferenceQueue – ReferenceQueue only required is there are elements in the WeakHashMap  Lazy allocation of ReferenceQueue saves 10.9MB in our example WeakHashMap 19,562 19,456 99.5
  • 48. © 2013 IBM Corporation48 Techniques for minimizing memory  Lazy allocation of collections – Don't create a collection until you have something to put into it  Don't create collections for a single Object! – Just store the Object itself  Size collections correctly – If only 2 entries will be stored, create with size 2: HashMap myHashMap = new HashMap(2);  Avoid expansion of large collections due to x2 algorithm – 32MB used to store 17MB of data  Collections do not shrink once expanded – May need to reallocate if collection uses drops significantly
  • 49. © 2013 IBM Corporation49 Summary  There is significant overhead to your data!  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
  • 50. © 2013 IBM Corporation50 http://ibm.co/JavaOne2013
  • 51. © 2013 IBM Corporation51 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
  • 52. © 2013 IBM Corporation52 Copyright and Trademarks © IBM Corporation 2013. 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