21
The Java Virtual Machine (JVM Short, French JVM), well known to Java developers, can interpret and execute the bytecode. The interest of the JVM is to enable the portability of languages it supports, ie, it allows them to operate on any platform.
How it works exactly?
Here is an overview of JVMs (Sun HotSpot):

We can see that the JVM is made up of different areas. This can be grouped into 2 main categories: the PERM and HEAP:

On loading the application, all classes (. Class) is loaded into this memory space. The JVM will then use the loaded classes in this space to create instances their bodies in the HEAP.
The HEAP consists of 2 generations of objects:
1. YOUNG GENERATION: This category represents the new objects. It is organized in 3 areas:
* EDEN: new objects are created in this area. When it reaches its maximum size, a first garbage collector (GC) (minor GC) moves objects in life (related to other objects) in the FROM.
* FROM: this area accommodates objects moved from the EDEN. When GC occurs and this area is full, objects are moved into life in the To box.
* TO: This area accommodates objects moved from the FROM. When GC occurs and this area is full, objects are moved into life in the area OLD.
2. OLD GENERATION: This category accommodates objects still alive after the successive garbage.
The JVM is composed of different memory area and its operation can be likened to a system of communicating vessels. The objects, created in a first zone, shifted gradually as in the following area where one of the area reached its maximum limit. This system is called the Garbage Collector. We can distinguish 2 types of garbage collector the major and minor.
When a new object is allocated on the heap, the JVM created in the Eden area. When this area reaches its maximum size the JVM Garbage Collector is launching a collection called minor. This is to cover all items of Eden and flags according to 2 criteria:
Living objects (objects live): Live objects are those with references to other objects.
Orphaned objects (Orpheans): orphaned objects (those with no reference).
The minor garbage collector, then removes orphans and moving objects in life zone to zone Eden From.This operation is repeated each time the Eden area is full. If the From field is full, objects are moved to the area to.
The major advantage of this algorithm lies in its execution speed (1 / 100 to 1 / 10 of a second) because there is no liberation of memory itself. In practice, the JVM just changes a pointer to the object alive. After a minor collection, the Eden and survivor space are considered free. The copy job is in turn supported by a characteristic of the current JVM, which means that all of the HEAP is a single continuous segment of memory. Over the minor collections, objects stuck in life are a survivor space to another.
We have seen that the minor garbage collections, reorganized the storage spaces of the Young Generation who filled in as and when. When it is saturated, the JVM needs to free memory. It will then invoke a major garbage collector called Full GC. This operation is very expensive, we’ll see why.

The JVM will stop all running threads to complete the analysis of memory. It determines the objects to be deleted (Orpheans) and those who must subsist. It then operates a copy of these items in the zone to zone Young Old (or tenured).
This is called a « stop the word collection » for his need to stop everything. It is very expensive (up to several seconds) also because processor for these operations sweep (delete / copy).
For great performance, it is preferable to configure the JVM to avoid unnecessary copies of the young tenured space.
We shall see in next section how to optimize the JVM and (especially) our code to avoid these costly copy.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.
very helpful…
I preferred to thank you for this good article. http://wtrjn.pimpblog.nl/ I by all odds liked every little bit of it…
Great…
love your blog, http://ksoney.jigsy.com/#dialog:close ,Thanks again….
Hello…
My life,vist it http://juhuacha.podbean.com/2011/09/02/marks-and-spencer-wedding-cakes/ ,Thanks….
Hello…
My life,vist it http://xiangcai8.insanejournal.com/292.html ,Thanks….
Great One…
Can my Limewire music be seen from the authorities when I download from iTunes? , http://www.bokee.net/bloggermodule/blogadmin_viewEntry.do?id=8977705...