Wednesday, January 2, 2013

JVM - the runtime data areas (Part 2/2)

Part 2 is continuation of Part 1. If you have not read Part 1 or want to review, please head here.

I have created some independent images which have a small program on each and the memory allocation being shown. As I informed in Part 1, our main concern will be three runtime areas, viz., Method Area, Heap Area, and Java Stacks Area, so I have only shown them in the following explanations.

• When you see some value being crossed, it means that either the default value has been replaced with initialized value, or in case of local variables, the value was changed.
• The execution flow is not explained, only memory allocation is shown.
• The Java Stacks Area has individual area for each thread.
By default, there are only 2 threads if we are not creating others. They are the main thread
    - shown as main in diagram,
    - it is the primary thread
    - not only our main method executes but also other methods
and the garbage collector thread
    - shown as either gc, or not shown at all because we are not using it.
    - run by the JVM, when we do not know yet, to clear of unreferenced objects.
• The Method Area contains the java.lang.Class's object inside which the data like static fields etc are loaded.
If you want more clarification, please post below. There we go with the examples.

No comments:

Post a Comment

Liked or hated the post? Leave your words of wisdom! Thank you :)