Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
༼ つ ◕_◕ ༽つ 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
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
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
staticinstance
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-HeapCode Cache
PermanentGeneration
Done?
object
༼ つ ◕_◕ ༽つ object ༼ つ ◕_◕ ༽つ
Method Area
JVM
Class stuff Class stuff Class stuff
Non-HeapPermanentGeneration
HEAP
PermanentGeneration
object
object
obj...
Young gen
JVM - The Heap
HEAP
Lol lol = new LOL();
lol
object object
object
JVM - The Heap
HEAP
PermanentGeneration
object
object
object
object
object
object
object
object
object
object
object
objec...
JVM - The Heap
HEAP
PermanentGeneration
object
object
object
object
object
object
object
object
object
object
object
objec...
Old gen
Young generation
JVM - The Heap
HEAPobject 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 ...
JVM - Sum up
Program Counter Stack
Frame
Frame
Frame
Frame
Heap Non-Heap
Object instances
Class Stuff/
Method Area
Similar...
༼ つ ◕_◕ ༽つ JVM ༼ つ ◕_◕ ༽つ
( ͡° ͜ʖ ͡°) JVM ( ͡° ͜ʖ ͡°)
Thanks!!
Questions?
@hannelita
hannelita@gmail.com
References
• http://www.artima.com/insidejvm/ed2/jvmP.html
• http://www.cubrid.org/blog/dev-platform/understanding-jvm-int...
JVM Internals Demystified
JVM Internals Demystified
Upcoming SlideShare
Loading in …5
×

JVM Internals Demystified

961 views

Published on

Confoo 2015

Published in: Technology
  • Be the first to comment

JVM Internals Demystified

  1. 1. ༼ つ ◕_◕ ༽つ JVM Internals ༼ つ ◕_◕ ༽つ Demystified! ( ͡° ͜ʖ ͡°) ༼ つ ◕_◕ ༽つ ༼ つ ◕_◕ ༽つ
  2. 2. What we will NOT see here • Pure JVM boring theory • Assembly fear stuff • 0xFF • 0100111
  3. 3. What we will see here • Why internals? • Method Area • Heap • Threads • Further reading • Funny Gifs and images!
  4. 4. Bonjour
  5. 5. Hi! I’m Hanneli São Paulo, Brazil
  6. 6. Hi! I’m Hanneli Meanwhile here in Canada
  7. 7. No advanced stuff Simplified way
  8. 8. If you understand computer architecture classes You understand JVM
  9. 9. Why do I Need to Understand Internals?
  10. 10. We live in a simplified era
  11. 11. All externalised
  12. 12. All externalised (Almost)Normal dressed developers (external)
  13. 13. Do I need internal details?
  14. 14. Developer showing internal details
  15. 15. Memory analyse • Help! Perm gem problems! • Search for memory leaks • Memory analyser tools • Understand how JVM works
  16. 16. What’s the relation between: JVM Memory Bytecode Assembly Low Level OpCode Operator Operation Java
  17. 17. How do I get started? • http://www.artima.com/insidejvm/ed2/jvmP.html
  18. 18. How do I get started?
  19. 19. JVM - Low level Assembly
  20. 20. I know how to write Java code
  21. 21. ༼ つ ◕_◕ ༽つ classes ༼ つ ◕_◕ ༽つ
  22. 22. What happens when I invoke a method in Java
  23. 23. WAIT How many kinds of methods do you know?
  24. 24. 2 types of methods Clazz.method(); object.method(); static instance
  25. 25. From Assembly classes: op code + operand operation + operand
  26. 26. operation + operand add r1, r2 public int add(int r1, int r2) operation operators == parameters
  27. 27. Method calls in JVM staticinstance operation + operand operation + operand invokevirtual invokestatic
  28. 28. Where are the Operands? Special place
  29. 29. Where are the Operands? Real place
  30. 30. Symbolic place called pool
  31. 31. JVM keeps this fake references It’s a strategy to deal with dynamic linking
  32. 32. While JVM does need the content of this fake box (pool), it remais unresolved
  33. 33. Each fake reference for each method is unique
  34. 34. Each fake reference for each method is unique So JVM can replace the fake calls with true invokes.
  35. 35. Back to methods Clazz.method(int a); object.method(parameter); class Lol { public int myMethod(int a){ // } } Class stuff
  36. 36. Method Area JVM Class stuff Class stuff Class stuff Non-HeapCode Cache PermanentGeneration
  37. 37. Done? object
  38. 38. ༼ つ ◕_◕ ༽つ object ༼ つ ◕_◕ ༽つ
  39. 39. Method Area JVM Class stuff Class stuff Class stuff Non-HeapPermanentGeneration HEAP PermanentGeneration object object object
  40. 40. Young gen JVM - The Heap HEAP Lol lol = new LOL(); lol object object object
  41. 41. JVM - The Heap HEAP PermanentGeneration object object object object object object object object object object object object object object object object Hey, Im’m heavy
  42. 42. JVM - The Heap HEAP PermanentGeneration 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
  43. 43. Old gen Young generation JVM - The Heap HEAPobject object Eden lol Survivor object Will be taken for GC
  44. 44. Last step Where does my application run?
  45. 45. Last step public static void main(String[] args){ …}
  46. 46. ༼ つ ◕_◕ ༽つ thread ༼ つ ◕_◕ ༽つ
  47. 47. JVM - Thread Thread Heap Non-Heap
  48. 48. 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
  49. 49. JVM - Sum up Program Counter Stack Frame Frame Frame Frame Heap Non-Heap Object instances Class Stuff/ Method Area Similar to Computer Architecture
  50. 50. ༼ つ ◕_◕ ༽つ JVM ༼ つ ◕_◕ ༽つ
  51. 51. ( ͡° ͜ʖ ͡°) JVM ( ͡° ͜ʖ ͡°)
  52. 52. Thanks!! Questions? @hannelita hannelita@gmail.com
  53. 53. 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

×