• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: WaekHashMap
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: WeakHashMap
      • From: Pierre Bernard <email@hidden>
References: 
 >WaekHashMap (From: Pierre Bernard <email@hidden>)

  • Prev by Date: Re: what happend of the .hidden file in Tiger?
  • Next by Date: Re: WeakHashMap
  • Previous by thread: WaekHashMap
  • Next by thread: Re: WeakHashMap
  • Index(es):
    • Date
    • Thread