You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Leon Rosenberg <ro...@googlemail.com> on 2006/08/01 22:45:36 UTC

[OT] A question on garbage collecting

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


Re: [OT] A question on garbage collecting

Posted by Leon Rosenberg <ro...@googlemail.com>.
Thank you Tamas,

On 8/2/06, Tamas Szabo <sz...@gmail.com> wrote:
> 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

Heh, getting help from sun? I think it's a myth!!! My best friends
girlfriend works for storagetek which now belongs to sun, and even
they don't get support.

regards
Leon


> :-)
>
> Tamas
>
>
> On 8/2/06, Leon Rosenberg <ro...@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
> >
> >
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [OT] A question on garbage collecting

Posted by Tamas Szabo <sz...@gmail.com>.
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 <ro...@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
>
>