about static variable  
Author Message
George2 via JavaKB.com





PostPosted: 2005-11-17 23:16:00 Top

java-programmer, about static variable Viv,


Viv wrote:
>I mean to say that the objects will get garbage collected but not the
>static variables. Class will remain in memory till the JVM shutdown.
>
>Roedy wrote :
>The only way you can recover the ram from a static class object is to
>load it with a custom classloader, then drop even the reference to the
>class loader.
>
>You can try what Roedy said.

What means "recover the ram from a static class object"? What do you mean
"recover"? I think there is not static class object -- only static class
members.

Do you know where can I find a sample dealing with how to write a customized
ClassLoader with the functions as you mentioned?


regards,
George


--
Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-setup/200511/1
 
George2 via JavaKB.com





PostPosted: 2005-11-17 23:16:00 Top

java-programmer >> about static variable Viv,


Viv wrote:
>I mean to say that the objects will get garbage collected but not the
>static variables. Class will remain in memory till the JVM shutdown.
>
>Roedy wrote :
>The only way you can recover the ram from a static class object is to
>load it with a custom classloader, then drop even the reference to the
>class loader.
>
>You can try what Roedy said.

What means "recover the ram from a static class object"? What do you mean
"recover"? I think there is not static class object -- only static class
members.

Do you know where can I find a sample dealing with how to write a customized
ClassLoader with the functions as you mentioned?


regards,
George


--
Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-setup/200511/1
 
George2 via JavaKB.com





PostPosted: 2005-11-17 23:20:00 Top

java-programmer >> about static variable Roedy,


Roedy Green wrote:
>>What mean "static class"? You mean the static variable of a class?
>
>There is a lump of memory reserved for the static variables of a
>class, and the methods themselves( both instance and static) There is
>also a java object associated with each class you can get at with
>.getClass(). Precisely how that is organised is not specified by the
>JVM spec or the language spec.
>
>So what I meant by that imprecise phrase "static class" is the
>per-class RAM overhead of the class.

"per-class RAM overhead "? What is it? Can you show your concept in a simple
sample? I am a little more confused. :-)


regards,
George


--
Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-setup/200511/1
 
 
Roedy Green





PostPosted: 2005-11-18 4:46:00 Top

java-programmer >> about static variable On Thu, 17 Nov 2005 15:15:53 GMT, "George2 via JavaKB.com"
<u14844@uwe> wrote, quoted or indirectly quoted someone who said :

>What means "recover the ram from a static class object"? What do you mean
>"recover"? I think there is not static class object -- only static class
>members.

If you have a class called Dog there is a corresponding Class object
called Dog.class. There is also an object in the JVM corresponding to
the class which is not directly accessible. It contains the static
fields, and the code for both static and instance members.

All that junk can be garbage collected if you loaded your class in a
custom classloader.

See http://mindprod.com/jgloss/classloader.html
http://mindprod.com/jgloss/garbagecollection.html
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
 
 
Roedy Green





PostPosted: 2005-11-18 4:47:00 Top

java-programmer >> about static variable On Thu, 17 Nov 2005 15:19:34 GMT, "George2 via JavaKB.com"
<u14844@uwe> wrote, quoted or indirectly quoted someone who said :

>
>"per-class RAM overhead "? What is it? Can you show your concept in a simple
>sample? I am a little more confused. :-)

You are asking about JVM internals, which are not even specified in
the JVM spec. For a start study the JVM spec. See
http://mindprod.com/jgloss/jasm.html
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.