🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.api
Article #280

Re: Hashtable keys

#280
From: Petar Banicevic
Date: Sat, 27 Mar 2004 21:51
44 lines
2445 bytes
Hi,

1) You can hear that GC uses reference counting, or mark and sweep mechanism
to sweep the heap, but it is up to the JVM implementation and you can't be
sure how it works. The only thing you can trust is the following definition:

2) Object is elibible for garbage collection when no live thread can access
it (including main thread!). It is incorrect to say that the object is
eligible for garbage collection when it has no references (case: islands of
insolation)

3) Islands of insolation is the case when you have several objects
cross-refering and none of them is reachable by any live thread. Then these
two objects are considered to be "islands of objects". GC will discover them
and sweep them out.

Your case with hashtable is case 3. You need to know whether any of objects
can be reached by living thread, including the Hashtable. If there is no
references to Hashtable and objects in Hashtable from live threads, then GC
will sweep them.

If there are refs to Hashtable they won't be sweeped.
If there are refs to objects but not to Hashtable, then only hashtable would
be sweeped.

HTH.
Regards.



"Jason Purcell" <purcelj@telkom.co.za> wrote in message
news:406030e5$2@newsgroups.borland.com...
>
> I have a Hashtable where the keys are Connection objects,
> and the values are Boolean objects.
>
> My question is: Will the Connection objects ever be
> garbage-collected while the Hashtable is still valid
> and being used?
>
> By extension, are keys in a Hashtable ever automatically
> removed?
>
> Jason.
Technical Details
Message-ID: <4065f73b@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <406030e5$2@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1089d0,54684b980608b0f4
X-Google-Attributes: gid1089d0,public
X-Google-ArrivalTime: 2004-03-27 14:09:27 PST
From: "Petar Banicevic" <petar2@kupi.biz>
Newsgroups: borland.public.jbuilder.java.api
References: <406030e5$2@newsgroups.borland.com>
Subject: Re: Hashtable keys
Date: Sat, 27 Mar 2004 22:51:44 +0100
Lines: 46
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 193.198.139.66
Message-ID: <4065f73b@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1080424251 193.198.139.66 (27 Mar 2004 13:50:51 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail