🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #18296

Re: I need help about Garbage Collector

#18296
From: Manfred Grebler
Date: Fri, 17 Jul 1998 00:00
40 lines
1887 bytes
William Yu wrote:
> Well, official you can use:
> 
>   System.gc();
> 
> You can do a simple test to verify this. Write a loop that creates
> 100,000 objects, frees the references, calls System.gc() and sleeps for
> a few seconds to allow gc() to work. If gc() worked as advertised, you
> would never get an out of memory error (the initial 100,000 objects must
> fit in available memory though).

You could try to use:

System.runFinalization();
System.gc();

Works for me. After adding these lines to my code at proper places I no
longer
get OutOfMemory when displaying large images.
The garbage collector can collect only those objects that have been
finalized before.
This is usually done by a low-prio finalization thread, but when you
create and release 
large objects in short time this thread cannot do its work. (Finalizing
your 100,000 
objects will take quite a bit of time!)


> Unfortunately, there is a design bug in JavaSoft's JVMs so the memory
> doesn't get freed to the OS. (Which in turn means the OS can't give this
> memory back to the JVM if required.)

I don't think this is quite true. You are right, that the JVM doesn't
release
memory back to the OS, but the VM will reuse this memory  to create new
Java
objects.


Manfred Grebler
Technical Details
Message-ID: <35AF0017.2DA7@privat.post.de>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <6ol371$8ld7@forums.borland.com> <35AEA062.66F95FBA@Bigfoot.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,9b781c15268687d4
X-Google-Attributes: gidf74b3,public
From: Manfred Grebler <manfred.grebler@privat.post.de>
Subject: Re: I need help about Garbage Collector
Date: 1998/07/17
Message-ID: <35AF0017.2DA7@privat.post.de>
X-Deja-AN: 372282197
Content-Transfer-Encoding: 7bit
References: <6ol371$8ld7@forums.borland.com> <35AEA062.66F95FBA@Bigfoot.com>
Content-Type: text/plain; charset=us-ascii
Organization: Another Netscape Collabra Server User
Mime-Version: 1.0
Newsgroups: borland.public.jbuilder.java.language