"I'm not back." - Bill Harding, Twister
Originally posted by Jim Yingst:
I've found that (contrary to documentation) the gc() method doesn't always "do its best",
Originally posted by Jim Yingst:
and the second (and sometimes third) successive call actually does free up more memory.
Originally posted by saumil shukla:
Is it possible to break down the query into parts? As per "Java 2 Certification Guide" -Simon Roberts etc. page 22, when ever a new object is created, it is stored on the heap however variable containing reference to it will be stored on stack.
Calling the gc method suggests that the Java Virtual Machine expend effort toward recycling unused objects in order to make the memory they currently occupy available for quick reuse. When control returns from the method call, the Java Virtual Machine has made a best effort to reclaim space from all discarded objects.
"I'm not back." - Bill Harding, Twister
From Chapter 9, "Garbage Collecion", of Inside the Java Virtual Machine" by Bill Venner
[/b]As you program in java, you must keep in mind that it is the garbage collector that runs finalizers on objects. [/b]
Because it is generally not possible to predict exactly when unreferenced objs will be gc-ed, it is not possible to predict when obj finalizers will be run.
As mentioned in Chapter 2, "Platform Independence", you should avoid writing programs for which correctness depends upon the timely finalization of objects. For ex., if a a finalizer of unreferenced obj releases a resource that is needed again later by the program, the resource will not be made available until after the garbage collector has run the object finalizer:"
From Introduction to Chapter 3 of JVM specs (before 3.1):
Implementation details that are not part of the Java virtual machine's specification would unnecessarily constrain the creativity of implementors. For example, the memory layout of run-time data areas, the garbage-collection algorithm used, and any internal optimization of the Java virtual machine instructions (for example, translating them into machine code) are left to the discretion of the implementor.
from 3.5.3 of JVM specs:
Heap storage for objects is reclaimed by an automatic storage management system (known as a garbage collector); objects are never explicitly deallocated. The Java virtual machine assumes no particular type of automatic storage management system, and the storage management technique may be chosen according to the implementor's system requirements.
from 3.5.4 of JVM specs:
The Java virtual machine has a method area that is shared among all Java virtual machine threads. The method area is analogous to the storage area for compiled code of a conventional language or analogous to the "text" segment in a UNIX process.
****************************
The method area is created on virtual machine start-up. Although the method area is logically part of the heap, simple implementations may choose not to either garbage collect or compact it. This version of the Java virtual machine specification does not mandate the location of the method area or the policies used to manage compiled code.
From Chapter 9, "Garbage Collecion", of Inside the Java Virtual Machine" by Bill Venner
As mentioned in earlier chapters, the Java virtual machine specification does not require any particular garbage collection technique. It doesn't even require garbage collection at all. But until infinite memory is invented, most Java virtual machine implementations will likely come with garbage-collected heaps.
Originally posted by Aaron Abraham:
...the memory utilizations remain at a high, and then, slowly crawls back to the normal levels (Note: this is not a typical GC 'drop'. I don't think GC is being done in this case). And the heap remains at high, and the application gets choked for memory...
"I'm not back." - Bill Harding, Twister
"I'm not back." - Bill Harding, Twister
MSc, BSc, SCJP 1.4<br /> <img src="graemlins/banghead.gif" border="0" alt="[banghead]" /> SCBCD
I didn't do it. You can't prove it. Nobody saw me. The sheep are lying! This tiny ad is my witness!
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|