tags:

views:

105

answers:

3

Messing about a bit, i have a working Adobe After Effects plugin with a bit of Obj-c / Cocoa in it (NSArray and custom objects - not ui stuff). The SDK guide states:-

Always use After Effects memory allocation functions. In low-memory conditions (such as during RAM preview), it’s very important that plug-ins not compete with After Effects for OS memory, and deal gracefully with out-of-memory conditions. Failing to use our functions can cause lock-ups, crashes, and tech support calls. Don’t do that. If you’re wrapping existing C++ code, overloading new and delete to use our functions will save substantial reimplementation. On Windows, derive all classes from a common base class which implements new and delete.

so my question.. is something compatible with the above statement possible in Obj-c?

I could probably swizzle alloc on NSObject if absolutely necessary, although i have no idea if something like NSArray uses NSObject's alloc method at all.

A: 

NSZone (which is what you'd need) is not extensible. CoreFoundation's allocators are extensible, but not everything you're allocating is a CF object underneath.

Unless you're allocating hundreds of megabytes of memory in your Objective-C code, I wouldn't worry.

Nicholas Riley
I guess the problem is that if you're working with After Effects content, it could easily be in the hundreds of megabytes as there's plenty of video, image and audio data being thrown around.
Rob Keniger
Sure, the question is whether this data is being allocated *as Objective-C objects* (which is really what I should have said above).
Nicholas Riley
Apologies, it seems i cannot vote for an answer without having an openID - which i do not want, but i do appreciate you (and the others) taking the time to help me out with this.So... when you say 'not extensible' i'm not sure what you mean. Looking at the NSZone docs for the first time it looks pretty promising..
mustISignUp
A: 

I think that this would be very difficult.

The memory allocation/deallocation of Objective-C objects is complex and messing with it would be much more dangerous than the risk of crashing After Effects by not using the AE allocation functions, in my opinion.

This is probably a question for Adobe. If they are supporting their app on the Mac then they really need to offer support for Cocoa/Objective-C as it's the currently supported development methodology.

If I were Adobe, I'd be adding some sort of notification of a low memory situation, similar to the -didReceiveMemoryWarning notification in the iPhone SDK. But that doesn't help you in your current situation.

Rob Keniger
A: 

I think it could be done, but if your UI isn't going to be Cocoa based, I also think it would be a lot easier for you to just not use NSArray.

Azeem.Butt