Problem with DeleteObj() and maxon::PointerArray
codysorgenfrey last edited by
I'm workinig on a c++ plugin in R18 on Mac with Xcode. When I create a new maxon::PointerArray<customtype> with NewObj() in GetVirtualObjects, everything is working great. The problem is when I go to free the pointer array with DeleteObj() after i'm done with it I get a EXC_BAD_ACCESS.
My question is, how do I free up this array? Do I need too, or does the auto memory management take care of it when it falls out of scope? It is local in my GetVirtualObjects method.
can you share some code to show that you are actually doing? Are you allocating the array or the objects stored in the array? If the array is a local variable, you can simply create in on the stack.
I haven't tried R18 (only have R20 currently available).
PointerArraytakes ownership of the stored objects. So it should not be needed to delete the objects manually. The objects are freed when the array is freed or reset.
You find an example (for R20) in the Arrays Manual.
codysorgenfrey last edited by codysorgenfrey
Ahhhh thanks! I couldn't find an Array Manual in the R18 documentation.
I was going like this:
maxon::PointerArray<MyCustomClass> myPointerArr = NewObj(maxon::PointerArray<MyCustomClass>); DoStuffWithArray(myPointerArr); DeleteObj(myPointerArr);
It seems my problem was with the PointerArray taking ownership of my pointers, then deallocating them before I was done with them. Since it doesn't seem that R18 has
maxon::UniqueRefobjects I decided to go with a
Thanks again for your help Sebastian!