Saturday, November 1, 2014

Java Compiler and Java Virtual Machine

Compile:

When a programmer finishes his Java code and click "Run":
1. Compiler: Java --> Byte code
2. Java Virtual Machine: Byte Code --> native binary
      Native binary is target specific, i.e: each target has its Native binary op-codes, which differs from other Target
       Ex: X86 Architecture have certain op-codes, Atmel Architecture has different op-codes, accordingly the native binary file (which can be defined as: the program written in terms of Architecture op-code) will be different.

The same happens when ".NET" code is compiled:
1. Compiler: C#,C++,VB, ...etc. --> Byte code
2. .NET Machine: Byte Code --> native binary


Dynamic Allocation:

Part of the functionality of the Java Virtual Machine, is to "malloc" objects in the heap during run time.
  • Object S = new Object(xx);     --> malloc
  • S = new Object(yy);               --> malloc for new object, the garbage collector frees the old one
  • S = null;                                --> free     (This is done by Grabage collector)


in .launch file:
VM_ARGUMENTS" value="-Dosgi.requiredJavaVersion=1.5 -Xms40m -Xmx384m"/>

In this line, the size of the heap used by the Java Virtual Machine (to "malloc" and "free" memory for the objects created in run time) is defined


Garbage Collector:
The Garbage Collector is responsible for "free" the unused parts in the Heap

No comments:

Post a Comment