LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   is there a way to free the resources of a created frame "explicitly" in java ?? (https://www.linuxquestions.org/questions/programming-9/is-there-a-way-to-free-the-resources-of-a-created-frame-explicitly-in-java-449479/)

alred 05-28-2006 11:49 PM

is there a way to free the resources of a created frame "explicitly" in java ??
 
if i create a child frame from within a frame(the main one) in java , how to free the child frame "explicitly" together with all its resources , are there any ways to do that ??

for eg ::

create new frameA ;
something done within frameA;
frameA.free;


//thanks in advance ...

.

paulsm4 05-29-2006 01:26 AM

The closest you can get is to explicitly set the reference to "null".

alred 05-30-2006 12:40 AM

so you are suggesting its better waiting for gc kicks in and clearing up ...


.

demon_vox 06-01-2006 11:55 AM

I agree with Paul. In Java there is no way to explicity remove an object from the virtual machine. It is the mision of the virtual machine to remove objects that no longer have any reference to it (if they have no reference to it, then they shouldnt be needed).
So thats why Paul said set it to "null", since this way you would eliminate the only reference you should have.

But thats part of the "hapiness" of using a virtual machine since I dont have to keep track of memory, pointers, space or whatsoever. It is magically managed for me (as usual, everything has a cost jaja)

You could explicity call the Garbage Collector, but no one assures that it will work right away or anything. You could write:

Runtime.getRuntime().gc();

I dont know if it is going to help you, but I must admit that it is a bit crazy.

Hope it is usefull for you :)

alred 06-01-2006 03:11 PM

>> "but I must admit that it is a bit crazy ..."

nop ... its not really crazy but a little bit weird ... kind of like "i cant even see you but its my memory !! even if i got it fried somehow ..." :D


ok ... serious ...

actually i can still see the working of the gc after passing some options to "java" ... when i give the options , something like '-XX:+UseConcMarkSweepGC' , '-XX:+PrintGCDetails' , '-Xms32m' , '-Xmx32m' , etc , etc , etc together with calling of gc to kick in ... yup , a little bit crazy but kind of fun ^_^ , the program does run a little bit more smoothly , at least it doesnt grow that fast but i guess java really force us to give "tighter" code or something ...

java virtual machine is a big thing and , "on and off" , i'm trying to absorb as much as possible only the very "normal" stuffs , later on probably i will go into constants and such ... one or two things at a time ...


btw , i think we dont actually need to give a "null" with later version , probably 1.4 upwards ...



//any suggestions or tricks are welcome ...


.


All times are GMT -5. The time now is 12:13 PM.