Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > freeing memory

Reply
Thread Tools

freeing memory

 
 
Rajesh.Rapaka
Guest
Posts: n/a
 
      04-20-2005
Hi,

I am using internal frame in my program. How can i free the memory it
used when i close and Internal frame ??

plz help.

regards,
Rajesh Rapaka.

 
Reply With Quote
 
 
 
 
Boudewijn Dijkstra
Guest
Posts: n/a
 
      04-20-2005
"Rajesh.Rapaka" <> schreef in bericht
news: oups.com...
> Hi,
>
> I am using internal frame in my program. How can i free the memory it
> used when i close and Internal frame ??


Dispose and set references to null.


 
Reply With Quote
 
 
 
 
Rajesh.Rapaka
Guest
Posts: n/a
 
      04-20-2005
Hi Boudewijn,

I've done that. But no use. I've even tried gc() and freememory()
funtions. neither helped.

any other ideas??

regards
Rajesh Rapaka.

 
Reply With Quote
 
Tony Morris
Guest
Posts: n/a
 
      04-20-2005

"Rajesh.Rapaka" <> wrote in message
news: oups.com...
> Hi Boudewijn,
>
> I've done that. But no use. I've even tried gc() and freememory()
> funtions. neither helped.
>
> any other ideas??
>
> regards
> Rajesh Rapaka.
>


Helped what?
Setting references to null does nothing more than set references to null -
don't be fooled by the ever dominant fallacies that exist out there.
Do you have a resource leak? Grab yourself a profiler and find it.

--
Tony Morris

JTiger Unit Test Framework for J2SE 1.5
http://www.jtiger.org/
Java Q&A (FAQ, Trivia)
http://qa.jtiger.org/
http://xdweb.net/~dibblego/


 
Reply With Quote
 
Rajesh.Rapaka
Guest
Posts: n/a
 
      04-20-2005
hi,

> Helped what?

Neither of the process helped in freeing the memory. I've set the
resources to null and garbage collected it. but this wouldnt help me in
freeing the memory. how can i free the memory?

regards
Rajesh Rapaka.

 
Reply With Quote
 
Tony Morris
Guest
Posts: n/a
 
      04-20-2005

"Rajesh.Rapaka" <> wrote in message
news: oups.com...
> hi,
>
> > Helped what?

> Neither of the process helped in freeing the memory. I've set the
> resources to null and garbage collected it. but this wouldnt help me in
> freeing the memory. how can i free the memory?
>
> regards
> Rajesh Rapaka.
>


You can't set a resource to null, nor can you garbage collect it, so it
seems you have a few concepts to brush up on.
Grab yourself a profiler and get cracking - usually only takes 20-30 seconds
to diagnose the issue if it's easily produced.

--
Tony Morris

JTiger Unit Test Framework for J2SE 1.5
http://www.jtiger.org/
Java Q&A (FAQ, Trivia)
http://qa.jtiger.org/
http://xdweb.net/~dibblego/


 
Reply With Quote
 
dave@yamoo.com
Guest
Posts: n/a
 
      04-20-2005
> Neither of the process helped in freeing the memory. I've set the
> resources to null and garbage collected it. but this wouldnt help me in
> freeing the memory. how can i free the memory?


You simply cannot free memory 'by hand'. If you set references to
null, it just means the the garbage-collector COULD free the memory
if it wants to.

And even if you call the garbage-collector yourself, that's just
a SUGGESTION to the VM to run the garbage-collector.

In reality, the garbage-collector will only start to free memory
if the memory on the computer is starting to run out (!).
 
Reply With Quote
 
HK
Guest
Posts: n/a
 
      04-20-2005

Rajesh.Rapaka wrote:
> Hi,
>
> I am using internal frame in my program. How can i free the memory it
> used when i close and Internal frame ??


Read about -XX:MinHeapFreeRatio=10 -XX:MaxHeapFreeRatio=10 and
then have a look at

http://www.ebi.ac.uk/Rebholz-srv/wha...onvinceGC.html

Harald.

 
Reply With Quote
 
.
Guest
Posts: n/a
 
      04-20-2005
On Wed, 20 Apr 2005, Rajesh.Rapaka wrote:

> hi,
>
> Neither of the process helped in freeing the memory. I've set the
> resources to null and garbage collected it. but this wouldnt help me in
> freeing the memory. how can i free the memory?


You cannot explicitly free memory in Java. You can set all references to
an object to null. If nothing is referencing the object that the garbage
collector SHOULD free the memory. If you want it to free immediately then
you can call System.gc(); and it might run the garbage collector right
away. Note that the API docs clear say that calling System.gc() SUGGESTS
that the JVM expend effort towards recycling ununsed objects.

Bottom line, you cannot guarantee that the system will reclaim the memory.

If you are getting OutOfMemoryExceptions and there are objects that you
believe have no references to them that are not getting freed then maybe
you have a memory leak. Google on "java memory leak" and you should find
some articles on it.

The most common problem is that you have a reference to the object and you
just don't realize it. For a large system it will tend to be a reference
to an object that has a reference to an object that has a reference to the
object you believe should be free. In other words, it is not always that
easy to spot.

--
Send e-mail to: darrell dot grainger at utoronto dot ca

 
Reply With Quote
 
Daniel Dyer
Guest
Posts: n/a
 
      04-20-2005
On Wed, 20 Apr 2005 13:48:48 +0100, <> wrote:

> In reality, the garbage-collector will only start to free memory
> if the memory on the computer is starting to run out (!).


That's not true, it depends on the JVM implementation (the JVM spec. does
not define how a garbage collector should behave) and its configuration.
Generally the heap cannot grow beyond a pre-configured maximum (-Xmx on
Sun VMs) so it will not use all of the computer's memory (unless you have
configured the heap to be allowed to grow that big).

Sun's VMs will increase the heap size as required but never reduce it.
With this behaviour the heap size would rapidly hit the maximum permitted
if they didn't ever perform garbage collection before the limit is reached.

System.gc() doesn't guarantee garbage collection will be performed, but it
usually is performed when this call is made.


Dan.

--
Daniel Dyer
http://www.footballpredictions.net
 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
memory allocation and freeing memory Rodrigo Dominguez C Programming 11 06-14-2005 11:54 PM
freeing memory Harald Kirsch Java 0 04-22-2005 09:17 AM
Freeing more Virtual Memory in Compaq Presario S4000NX Bun Mui Computer Support 2 05-22-2004 08:46 PM
freeing memory....partially f.oppedisano@tiscalinet.it C Programming 12 10-06-2003 08:07 AM
some queries on freeing memory allocated using malloc Hassan Iqbal C Programming 3 09-25-2003 02:53 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57