Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JVM behavior and garbage collection

 
Shanky Sohar
Ranch Hand
Posts: 1051
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Atul Darne
Ranch Hand
Posts: 118
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Shanky Sohar
Ranch Hand
Posts: 1051
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 5432
52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1051
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes you are right....

I will consider JLS for that....But i was searching for some book for studying JVM...
 
Stephan van Hulst
Bartender
Pie
Posts: 5432
52
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1051
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I already understood your feeling when i was searching for that...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic