Thread View: borland.public.jbuilder.java.api
3 messages
3 total messages
Started by Jason Purcell
Tue, 23 Mar 2004 12:43
Hashtable keys
Author: Jason Purcell
Date: Tue, 23 Mar 2004 12:43
Date: Tue, 23 Mar 2004 12:43
12 lines
1121 bytes
1121 bytes
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.
Re: Hashtable keys
Author: Lori M Olson (TeamB)
Date: Thu, 25 Mar 2004 02:48
Date: Thu, 25 Mar 2004 02:48
40 lines
2136 bytes
2136 bytes
Jason Purcell wrote:
> 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.
Be garbage collected? -- No. They are in the hash table, so their
reference count will be greater than zero.
Note that just because the Connection objects are there, doesn't mean
that the connections will still be valid/open. They will time-out.
"Automatically removed"? -- No. Where did you get that idea, anyway?
--
Regards,
Lori Olson (TeamB)
------------
Save yourself, and everyone else, some time and search the
newsgroups and the FAQ-O-Matic before posting your next
question.
Google Advanced Newsgroup Search
http://www.google.ca/advanced_group_search
Other Newsgroup Searches:
http://www.borland.com/newsgroups/ngsearch.html
Joi Ellis's FAQ-O-Matic:
http://www.visi.com/~gyles19/fom-serve/cache/1.html
Re: Hashtable keys
Author: Petar Banicevic
Date: Sat, 27 Mar 2004 21:51
Date: Sat, 27 Mar 2004 21:51
44 lines
2445 bytes
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.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads