Search code examples
c++memory-managementobjective-c++nsobject

Own memory management in Objective-C++


For C++ code I can manage memory on my own by using placement new/delete operator and their arraycounterparts.

Now I‘d like to use my memory manager also for Objective-C code. I thought about replacing NSObject‘s alloc: and dealloc: methods, but poseAsClass: doesn‘t work any longer. So: How can I force it using my memory manager? Or am I completly on a wrong path?


Solution

  • Think you're on a wrong path - the fundamentals of how the reference counting (and indeed garbage collection on non iOS devices) work are, I suspect, too embedded into the language implementation to make this a realistic possibility.

    I also don't understand why you'd want to do this, unless you've a particular fondness for re-inventing wheels.