THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 26/01/2009 at 08:38, xxxxxxxx wrote:
Cinema 4D Version: 11
Platform: Mac ;
Language(s) : C++ ;
I found out that this code crashes on Mac.
Can anyone confirm? For a small workaround I put all the deallocation stuff
into PluginMessage with the ID C4DPL_ENDACTIVITY which seems to work there.
op = BaseObject::Alloc(Ocube);
BaseObject::Free(op); //crashes here
Bool PluginMessage(LONG id, void *data)
Thanks and bye
On 26/01/2009 at 09:10, xxxxxxxx wrote:
Is 'op' ever inserted into a BaseDocument?
Also, I wouldn't trust using global variables except under specific circumstances. Do a forum search for __WINCRTINIT.
On 26/01/2009 at 10:03, xxxxxxxx wrote:
Yes, you are right, it was just an example. I don't use global variables here. It was just an example to show that it crashes, when I free a GeListeNode object.
On 29/01/2009 at 06:05, xxxxxxxx wrote:
can anyone confirm that? thx
On 29/01/2009 at 08:14, xxxxxxxx wrote:
I can confirm this.
You have to use C4DPL_ENDACTIVITY and C4DPL_STARTACTIVITY for allcoations/deallocations which depend on other plugins.
You allocate a BaseObject (a cube) which is probably just another plugin by itself.
Besides this the use of global static classes is forbidden (not your case since it's just a pointer).
From the techinfo paper:
Stability and Testing
• Crashes due to use of global static classes
• Crashes happen randomly and are often hard to reproduce
• Allowed are elementary datatypes and datatypes that don't need to be allocated (LONG, Real, CHAR, GE_SPINLOCK etc.)
• Any other SDK datatype cannot be placed in the global scope
AutoAlloc <String> my_global_string1;
On 06/03/2009 at 02:15, xxxxxxxx wrote:
At first I checked out several cases and thought the object is not owned by my plugin but thats not the case.
In PluginEnd I deallocate and clean up some allocated objects(BaseDocuments, BaseObjects, etc.) which were created in the sandbox. Well, I would do all that in C4DPL_ENDACTIVITY but thats not possible. So imagine the following case:
Someone creates an object of BaseDocument in the sandbox. The sandbox is similar to the standard console and is just a terminal. So if you type
doc = get_active_document.get_clone() you get a clone of the document which is stored in the sandbox and the object is alive until the sandbox is closed and freed which happens in PluginEnd().
gDelete(glob->sandbox); the deconstructor cleans up all allocated objects. So imagine there is a BaseDocument like the example above so Py4D calls BaseDocument::Free(objectA); which crashs on Mac OSX but not on Windows. Interesting point: BaseBitmap::Free(objectB); does not crash in PluginEnd().
So I set a global flag called "finalize" that BaseDocument::Free() will not be executed, if this is called from the cleanup management in PluginEnd. That means, there are memory leaks on Mac OSX. Is there another workaround?