struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tamas Szabo" <szab...@gmail.com>
Subject Re: [OT] A question on garbage collecting
Date Wed, 02 Aug 2006 00:49:12 GMT
Hi Leon,

I doubt I have more experience :-) but as I know soft references are
collected when the GC decides to do so.

The only thing you can be sure of is that they will be collected _if_ the VM
is running out of memory.
But there is no guarantee that they will not be collected before.

You are right, it is weird because you usually use them for caches but, I
guess that it is VM-implementation specific.
Maybe if you use another VM, or try to find some help from your VM providers
:-)

Tamas


On 8/2/06, Leon Rosenberg <rosenberg.leon@googlemail.com> wrote:
>
> Hi,
>
> I have a question regarding a weird behaviour of the garbage
> collector, maybe someone here, has more experience with it, and can
> answer the question. Otherwise sorry for the OT.
>
> We have a cache for caching 1000.000 user objects along with many
> (some hundred thousand) not existing objects (negative cachingto
> prevent db requests). The cache is an array of softreferences to the
> objects. We used softreferences to prevent oome in case we don'T have
> enough ram. However now we do have enough ram - 6 Gb assigned to the
> java process, and System.freeMemory is always above 1 gig.
>
> However, I see that through the cache isn't full yet, and there is
> plenty of free memory, 500.000 objects have been garbage collected.
>
> Could it be that softreference are collected independent of available
> memory? If true, isn't it weird? ;-(
>
> regards
> Leon
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message