Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

memory management  RSS feed

 
raj joe
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone guide me to some good stuff on web related to Java memory allocation(What happens on Stack and what happens on Heap),Management,Garbage collection.
 
Virag Saksena
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What exactly are you looking for ? Here is a brief overview of stack vs Heap in Java
1. The stack contains local variables
2. First local variable is always the instance object (class for static methods)
3. Other local variables are parameters passed to the method and and method variables
4. Per the JVM specification - if the local is an object, it is allocated on the heap, and the local variable just contains a reference to the object. If the local is a primitive, then the actual value is there on the stack.

All objects are allocated on the heap (so far, there are changes afoot where the locals with limited scope could actually come out of the stack).

Most of the heap consists of instance objects and arrays. There are other types of objects too like the Classes, Methods, Symbols, Constant Pools.

If you use the Advanced Heap Analysis in Auptyma's Java Application Monitor, it will show you the type of objects inside the Heap and their relationships.

For Heap Management and Garbage Collection - there is a good paper on GC on the Sun web-site. IBM JVM is a little different with thread local heaps too and they talk about it on DeveloperWorks. If you really want to understand the parallel GC then read the train GC, there is a paper which came out in 1991 or so.

Regards,

Virag Saksena
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!