THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 27/09/2008 at 08:34, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 9
Platform: Windows ;
Language(s) : C++ ;
---------
Hello fellow devs ;-)
i have this strange crash with my paintonsurface plugin which i dont understand.
It only happens when i use the stacking feature to paint objects on top of other painted objects (stacking), and only if i stack so much that editor performance gets really choppy. if i use the feature only modestly everything is fine.
the crash seems to be due to freeing some temp object (scCopy),which is needed during the stacking process. Freeing works fine when i stack only modestly, and editor display is still fluid.
if i dont free, it doesnt crash anymore, but ofc i get memleaks, which is why i need the free.
here's the code snippet, freeing is at the bottom..
--------------
<CODE>
.
.
BaseObject* scCopy = NULL;
BaseObject* copy = NULL;
ModelingCommandData md1;
// init rayCollider with object to check ray collisions on
if(stackClones && mode==POS_MODE_OBJECT){
// make a copy of the object
scCopy = (BaseObject* )obj->GetClone(COPY_NO_ANIMATION,NULL);
scCopy->SetName("objCopy");
scCopy->SetPos(Vector(0,0,0)); scCopy->SetRot(Vector(0,0,0));
md1.op = scCopy; md1.doc = doc;
if(!SendModelingCommand(MCOMMAND_CURRENTSTATETOOBJECT, md1)) return NULL;
BaseObject::Free(md1.op);
md1.op = static_cast<BaseObject*>(md1.result->GetIndex(0));
AtomArray::Free(md1.result);AtomArray::Free(md1.arr);
if(!SendModelingCommand(MCOMMAND_JOIN, md1)) return NULL;
copy = static_cast<BaseObject*>(md1.result->GetIndex(0));
BaseObject::Free(md1.op);AtomArray::Free(md1.result);AtomArray::Free(md1.arr);
.
.
.
.
// later temp objects from above get free'd, when they are not needed anymore
.
.
if(stackClones){
// free stuff not needed anymore, to prevent mem leaks
// ..
// unfortunately, if we use lots of stacking, cinema crashes bc of this :(
// maybe bc system is stressed too much when stacking heavily? editor fps is like <5 before crashing..
// if stress is less, no crashes happen..
BaseObject::Free(scCopy);
}
.
.
[\CODE]
i really cant see anything wrong with this, as it usually works, unless i stack too much..
strange thing is, in the R9 console, i get this:
(but not in R11 console, but R11 crashes too) :
DebugOut:
C4D Trace Start...
Memory Start Corrupt
Memory Corrupt!
F:\work9.x\src\Richard\Genesis\ge_memory.cpp<950> : ALERT
the last line must be sth from a maxon dev, as i dont have drive F: ..
so could it be, that with the code everything is alright, and its just that my memory is faulty?
so that maybe when a certain address is reached, the crash happens ?
thanks,
Daniel