LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-28-2006, 11:49 PM   #1
alred
Member
 
Registered: Mar 2005
Location: singapore
Distribution: puppy and Ubuntu and ... erh ... redhat(sort of) :( ... + the venerable bsd and solaris ^_^
Posts: 658
Blog Entries: 8

Rep: Reputation: 31
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 ...

.

Last edited by alred; 05-28-2006 at 11:51 PM.
 
Old 05-29-2006, 01:26 AM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
The closest you can get is to explicitly set the reference to "null".
 
Old 05-30-2006, 12:40 AM   #3
alred
Member
 
Registered: Mar 2005
Location: singapore
Distribution: puppy and Ubuntu and ... erh ... redhat(sort of) :( ... + the venerable bsd and solaris ^_^
Posts: 658

Original Poster
Blog Entries: 8

Rep: Reputation: 31
so you are suggesting its better waiting for gc kicks in and clearing up ...


.
 
Old 06-01-2006, 11:55 AM   #4
demon_vox
Member
 
Registered: May 2006
Location: Argentina
Distribution: SuSE 10
Posts: 173

Rep: Reputation: 30
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
 
Old 06-01-2006, 03:11 PM   #5
alred
Member
 
Registered: Mar 2005
Location: singapore
Distribution: puppy and Ubuntu and ... erh ... redhat(sort of) :( ... + the venerable bsd and solaris ^_^
Posts: 658

Original Poster
Blog Entries: 8

Rep: Reputation: 31
>> "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 ..."


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 ...


.

Last edited by alred; 06-01-2006 at 03:21 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Differences between the "free" and "paid" versions eraser Linux - General 4 11-18-2015 06:30 PM
"Frame check sequence"-error (802.11b Ad hoc) rickthemick Linux - Wireless Networking 2 08-21-2008 10:04 AM
Can you explain the difference between "Free Software (GNU)" and "Open Source"? vharishankar General 5 03-03-2005 09:40 AM
Java error "Exception in thread "main" java.lang.StackOverflowError" nro Programming 1 09-04-2004 03:47 AM
I cannot use "java chat". Browser says plugin required "x-java-vm". jdruin Linux - Software 4 04-18-2004 05:44 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:22 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration