Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
JVM Internals Demystified
Search
hannelita
February 19, 2015
Technology
0
330
JVM Internals Demystified
Confoo 2015
hannelita
February 19, 2015
Tweet
Share
More Decks by hannelita
See All by hannelita
Java EE 8 - Future, Wishes and Predictions
hannelita
1
190
Eletrônica
hannelita
0
160
Cassandra Meetup
hannelita
0
52
Our Daily Graphs written in Ruby and Neo4j
hannelita
1
150
Wildfly em alta disponibilidade
hannelita
0
220
Helios - o backend pra Mobile que você precisava <3
hannelita
0
100
Neo4j - Dia a dia com grafos, Neo4j e Ruby
hannelita
1
120
Swift - uma fama repentina
hannelita
1
120
Curso relâmpago de eletrônica básica para desenvolvedores
hannelita
1
190
Other Decks in Technology
See All in Technology
【Developers Summit 2025】プロダクトエンジニアから学ぶ、 ユーザーにより高い価値を届ける技術
niwatakeru
2
1.2k
SA Night #2 FinatextのSA思想/SA Night #2 Finatext session
satoshiimai
1
130
レビューを増やしつつ 高評価維持するテクニック
tsuzuki817
1
480
Datadogとともにオブザーバビリティを布教しよう
mego2221
0
130
データ資産をシームレスに伝達するためのイベント駆動型アーキテクチャ
kakehashi
PRO
2
470
明日からできる!技術的負債の返済を加速するための実践ガイド~『ホットペッパービューティー』の事例をもとに~
recruitengineers
PRO
3
290
スクラムのイテレーションを導入してチームの雰囲気がより良くなった話
eccyun
0
110
株式会社EventHub・エンジニア採用資料
eventhub
0
4.2k
Data-centric AI入門第6章:Data-centric AIの実践例
x_ttyszk
1
390
スタートアップ1人目QAエンジニアが QAチームを立ち上げ、“個”からチーム、 そして“組織”に成長するまで / How to set up QA team at reiwatravel
mii3king
2
1.3k
The Future of SEO: The Impact of AI on Search
badams
0
160
白金鉱業Meetup Vol.17_あるデータサイエンティストのデータマネジメントとの向き合い方
brainpadpr
4
300
Featured
See All Featured
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
2.1k
Visualization
eitanlees
146
15k
Code Reviewing Like a Champion
maltzj
521
39k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Into the Great Unknown - MozCon
thekraken
35
1.6k
Making Projects Easy
brettharned
116
6k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
248
1.3M
The Power of CSS Pseudo Elements
geoffreycrofte
75
5.5k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
29
2.2k
The World Runs on Bad Software
bkeepers
PRO
67
11k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
7k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
49
2.3k
Transcript
༼ つ ◕_◕ ༽つ JVM Internals ༼ つ ◕_◕ ༽つ
Demystified! ( ͡° ͜ ʖ ͡°) ༼ つ ◕_◕ ༽つ ༼ つ ◕_◕ ༽つ
What we will NOT see here • Pure JVM boring
theory • Assembly fear stuff • 0xFF • 0100111
What we will see here • Why internals? • Method
Area • Heap • Threads • Further reading • Funny Gifs and images!
Bonjour
Hi! I’m Hanneli São Paulo, Brazil
Hi! I’m Hanneli Meanwhile here in Canada
None
No advanced stuff Simplified way
If you understand computer architecture classes You understand JVM
Why do I Need to Understand Internals?
We live in a simplified era
All externalised
All externalised (Almost)Normal dressed developers (external)
Do I need internal details?
Developer showing internal details
Memory analyse • Help! Perm gem problems! • Search for
memory leaks • Memory analyser tools • Understand how JVM works
What’s the relation between: JVM Memory Bytecode Assembly Low Level
OpCode Operator Operation Java
None
How do I get started? • http://www.artima.com/insidejvm/ed2/jvmP.html
How do I get started?
JVM - Low level Assembly
I know how to write Java code
༼ つ ◕_◕ ༽つ classes ༼ つ ◕_◕ ༽つ
What happens when I invoke a method in Java
WAIT How many kinds of methods do you know?
2 types of methods Clazz.method(); object.method(); static instance
From Assembly classes: op code + operand operation + operand
operation + operand add r1, r2 public int add(int r1,
int r2) operation operators == parameters
Method calls in JVM static instance operation + operand operation
+ operand invokevirtual invokestatic
Where are the Operands? Special place
Where are the Operands? Real place
Symbolic place called pool
JVM keeps this fake references It’s a strategy to deal
with dynamic linking
While JVM does need the content of this fake box
(pool), it remais unresolved
Each fake reference for each method is unique
Each fake reference for each method is unique So JVM
can replace the fake calls with true invokes.
Back to methods Clazz.method(int a); object.method(parameter); class Lol { public
int myMethod(int a){ // } } Class stuff
Method Area JVM Class stuff Class stuff Class stuff Non-Heap
Code Cache Permanent Generation
Done? object
༼ つ ◕_◕ ༽つ object ༼ つ ◕_◕ ༽つ
Method Area JVM Class stuff Class stuff Class stuff Non-Heap
Permanent Generation HEAP Permanent Generation object object object
Young gen JVM - The Heap HEAP Lol lol =
new LOL(); lol object object object
JVM - The Heap HEAP Permanent Generation object object object
object object object object object object object object object object object object object Hey, Im’m heavy
JVM - The Heap HEAP Permanent Generation object object object
object object object object object object object object object object object object object Checks all the objects on the heap Garbage collector
Old gen Young generation JVM - The Heap HEAP object
object Eden lol Survivor object Will be taken for GC
Last step Where does my application run?
Last step public static void main(String[] args){ …}
༼ つ ◕_◕ ༽つ thread ༼ つ ◕_◕ ༽つ
JVM - Thread Thread Heap Non-Heap
JVM - Thread Thread Program Counter Stack Frame Frame Frame
Frame Frame Local variables [] Return Value Pointer to Method Area Pointer to Heap Area Operand Operand Operand Operand Stack
JVM - Sum up Program Counter Stack Frame Frame Frame
Frame Heap Non-Heap Object instances Class Stuff/ Method Area Similar to Computer Architecture
༼ つ ◕_◕ ༽つ JVM ༼ つ ◕_◕ ༽つ
( ͡° ͜ ʖ ͡°) JVM ( ͡° ͜ ʖ
͡°)
Thanks!! Questions? @hannelita
[email protected]
References • http://www.artima.com/insidejvm/ed2/jvmP.html • http://www.cubrid.org/blog/dev-platform/understanding-jvm-internals/ • http://architects.dzone.com/articles/understanding-jvm-internals • http://www.ourdailycodes.com/2013/09/inside-java-jvm-memory- structure-2.html
• http://javarevisited.blogspot.ca/2011/04/garbage-collection-in-java.html • http://www.slideshare.net/BalamuruganSoundararajan/invoke-dynamics • http://www.javaworld.com/article/2076949/learn-java/how-the-java-virtual- machine-handles-method-invocation-and-return.html • http://blog.jamesdbloom.com/JVMInternals.html#threads