Bug in R11?
-
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:
User Information:
Cinema 4D Version: 11
Platform: Mac ;
Language(s) : C++ ;---------
Hi!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.#include "c4d.h"
BaseObject *op;
Bool PluginStart(void)
{
op = BaseObject::Alloc(Ocube);
return TRUE;
}void PluginEnd(void)
{
BaseObject::Free(op); //crashes here
}Bool PluginMessage(LONG id, void *data)
{
return TRUE;
}Thanks and bye
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
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.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 26/01/2009 at 10:03, xxxxxxxx wrote:
Hi!
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.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 29/01/2009 at 06:05, xxxxxxxx wrote:
can anyone confirm that? thx
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
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 scopeWrong!
AutoAlloc <String> my_global_string1;
Stringmy_global_string2;
Filenamemy_global_filename;cheers,
Matthias -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 06/03/2009 at 02:15, xxxxxxxx wrote:
Hi!
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?
bye...