Re: WaekHashMap
Re: WaekHashMap
- Subject: Re: WaekHashMap
- From: Michel Schinz <email@hidden>
- Date: Sun, 28 Aug 2005 09:05:19 +0200
Le 22 août 05 à 15:09, Pierre Bernard a écrit :
Now I don't want to leak memory. I would like the view to go away
if the NSManagedObject is deleted. here the Java programme in me
longs for a WeakHashMap, where entries go away when their key does.
No such luck in absence of a garbage collector.
One idea could be to do the garbage collection yourself. That is, you
periodically walk over all the entries of your dictionary, look at
the retain count of the business object represented by the key (using
the "retainCount" method), and if it is equal to one, you know that
you have the only reference to it. You therefore remove it from the
dictionary, which should release and de-allocate it.
This only works if you are sure that any object belongs to at most
one such weak dictionary. If it isn't the case, you need to do some
additional work.
Michel.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
References: | |
| >WaekHashMap (From: Pierre Bernard <email@hidden>) |