Skip to Content
Java 9 High Performance
book

Java 9 High Performance

by Mayur Ramgir, Nick Samoylov
November 2017
Intermediate to advanced
398 pages
10h 14m
English
Packt Publishing
Content preview from Java 9 High Performance

Escape analysis

As we have seen, objects live in the heap memory and heap memory is slower than stack. Every object on the heap has a lock, which ensures mutual exclusion upon invoke from a synchronized method or block. Heap and synchronization add performance overhead. Moreover, getting unused objects out of heap is very expensive from the performance point of view. On the other hand, stack memory is cheaper to clear as the JVM destroys the stack as soon as the method returns.

Also, JVM manages the stack memory properly and its deallocation is free, which speeds up the performance remarkably. I am sure you must be scratching your head and thinking, can we find a way to store an object in the stack memory than heap memory? If we could do ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Distributed Computing in Java 9

Distributed Computing in Java 9

Raja Malleswara Rao Malleswara Rao Pattamsetti
Mastering Java 11 - Second Edition

Mastering Java 11 - Second Edition

Dr. Edward Lavieri Jr., Mandar Jog
Java EE 8 High Performance

Java EE 8 High Performance

Romain Manni-Bucau
Clojure: High Performance JVM Programming

Clojure: High Performance JVM Programming

Eduardo Díaz, Shantanu Kumar, Akhil Wali

Publisher Resources

ISBN: 9781787120785Supplemental Content