aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes JVM behavior and garbage collection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "JVM behavior and garbage collection" Watch "JVM behavior and garbage collection" New topic
Author

JVM behavior and garbage collection

Shanky Sohar
Ranch Hand

Joined: Mar 17, 2010
Posts: 1051

Hi Friends.

I need to learn the internal things in Java Like how the JVM behaves for a Particular code and how the garbage collection works...
so can you please help me with the book which will guide me the same..


Thanks
Shanky


SCJP6.0,My blog Ranchers from Delhi
Atul Darne
Ranch Hand

Joined: Jul 05, 2009
Posts: 118

1) objects are created on heap in Java irrespective of there scope e.g. local or member variable. while its worth noting that class variables or static members are created in method area of Java memory space and both heap and method area is shared between different thread.
2) Garbage collection is a mechanism provided by Java Virtual Machine to reclaim heap space from objects which are eligible for Garbage collection.
3) Garbage collection relieves java programmer from memory management which is essential part of C++ programming and gives more time to focus on business logic.
4) Garbage Collection in Java is carried by a daemon thread called Garbage Collector.
5) Before removing an object from memory Garbage collection thread invokes finalize () method of that object and gives an opportunity to perform any sort of cleanup required.
6) You as Java programmer can not force Garbage collection in Java; it will only trigger if JVM thinks it needs a garbage collection based on Java heap size.
7) There are methods like System.gc () and Runtime.gc () which is used to send request of Garbage collection to JVM but it’s not guaranteed that garbage collection will happen.
8) If there is no memory space for creating new object in Heap Java Virtual Machine throws OutOfMemoryError or java.lang.OutOfMemoryError heap space
9) J2SE 5(Java 2 Standard Edition) adds a new feature called Ergonomics goal of ergonomics is to provide good performance from the JVM with minimum of command line tuning.

You can have more details on Link


Regards, Atul.
I came to this world on a Learner's License
Shanky Sohar
Ranch Hand

Joined: Mar 17, 2010
Posts: 1051

Atul Darne wrote:



Thanks Atul...But this is not enough for me...i need more to understand....By the way thanks...
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3646
    
  16

Well, your question is very broad. For a conclusive answer you should read the JLS, but this is hardly easy reading.

To get a feeling for what a piece of software like the JVM does, you need a fair bit of understanding in the field of operating systems, computer architecture, data structures and algorithms.

Maybe you have some specific questions you would like to have answered?
Shanky Sohar
Ranch Hand

Joined: Mar 17, 2010
Posts: 1051

yes you are right....

I will consider JLS for that....But i was searching for some book for studying JVM...
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3646
    
  16

Oh I'm sorry, I said JLS, but I was thinking of the JVMS: http://java.sun.com/docs/books/jvms/second_edition/html/VMSpecTOC.doc.html

However, the JLS itself should also provide plenty of information.
Shanky Sohar
Ranch Hand

Joined: Mar 17, 2010
Posts: 1051

I already understood your feeling when i was searching for that...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JVM behavior and garbage collection