Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JIT(Just In Tim) compiler

 
T Rai
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi folks,
i again ran into a term JIT. what is it? and how does it differ with JRE?
I read that Garbage collection scheme can vary dramatically across JVM implementaions. what does that mean?
thanks.
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JIT is an acronym for Just In Time compiler. Java is an interpreted language. Interpreted language are generally slow beasts by nature. What a JIT does is optimizes calls at runtime using the native platform language to speed things up. The speed of Java applications now rival that of native applications because of JITs.
Garbage collection is one of the better aspects of Java. The language it was designed after, C++, has no such facility. The developer had to provide destructors to free resources whenever an object became orphaned. In deep inheritance trees, sometimes destructors would not be called as expected because a developer neglected to create a virtual destructor or override a destructor. This problem led to what is known as memory leaks, the program would eventually be starved for memory because orphaned objects would still be holding on to the memory that was allocated to them. The Java Garbage Collector or GC, keeps up with all object references and when it determines that there are no reachable references to an object it marks that object for garbage collection. When will the object be GCed? When the GC decides it needs the resources. The programmer has little control over it. He can suggest that everything be GCed by calling System.gc(), but in reality it is still up to the GC to actually clean up the orphaned objects as its whim. There is a lot of room for interpretation for how GC should be accomplished by the Java specifications so different JVM vendors will certainly do it in varying ways.
 
John Lee
Ranch Hand
Posts: 2545
 
Bert Bates
author
Sheriff
Posts: 8900
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thulung -
Just to add a bit to what Michael said:
It won't really matter to you how the GC has been implemented. What *is* important is that you understand how to make sure that objects you're not using any more are eligible to be destroyed by the GC. If your program is creating a lot of large objects, it is good practice to make sure that all of the references to these objects are nulled or reassigned when you are done with the objects.
Once all of an object's references have been removed, the GC can destroy that object if it needs to.
 
T Rai
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you all for your help. i appreciate.
 
John Lee
Ranch Hand
Posts: 2545
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you are welcome!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic