• 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: deallocation of related objects
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: deallocation of related objects


  • Subject: Re: deallocation of related objects
  • From: Karl Kraft <email@hidden>
  • Date: Tue, 11 Mar 2003 18:17:43 -0800

On Tuesday, March 11, 2003, at 05:31 PM, Daryn wrote:

I have an interesting problem for which I'd like implementation suggestions. In the general sense, I need to be able to be able to invisibly attach metadata to any existing objc object. When the object is destroyed, then the metadata needs to be freed.

Do you really need to be able to attach it to any Objective-C object?

Take the pointer to the instance

Allocate enough memory to hold the object plus your additional state, and copy the object structure into the new memory.

Swizzle the isa at the original memory address to be a proxy object that forwards requests to the new object, and manages the added state.

realloc the original memory space down to just enough bytes to hold your isa.

Pray that no where in the calling chain that someone still has a ref to the original memory space.

Catch the deallocs and take care of both objects.


Is this implementation better than the one you outlined? It depends on whether on how many total objects you have, and how many you map and many other factors.



--
To purchase it is not like spending money
but rather it is an investment in the future
in a blow against the empire
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: deallocation of related objects
      • From: Daryn <email@hidden>
References: 
 >deallocation of related objects (From: Daryn <email@hidden>)

  • Prev by Date: deallocation of related objects
  • Next by Date: Re: deallocation of related objects
  • Previous by thread: deallocation of related objects
  • Next by thread: Re: deallocation of related objects
  • Index(es):
    • Date
    • Thread