I cannot for the life of me find this memory leak. I keep getting this:
(0, 0) : ERR : GC cannot free an object of type 'RenderComponent', it is kept alive by the application
(0, 0) : ERR : GC cannot free an object of type '_builtin_objecttype_', it is kept alive by the application
(0, 0) : ERR : GC cannot free an object of type 'dictionary', it is kept alive by the application
(0, 0) : ERR : GC cannot free an object of type 'Sprite', it is kept alive by the application
I implement all of these functions:
void addRef();
void release();
int getRefCount();
void setGCFlag();
bool getGCFlag();
in the constructor i set the refCount to 1
and when I create a script object I notify the garbage collector like so:
SpriteScripted* ScriptObjectCreationCache::SSFactory() {
SpriteScripted* obj = new SpriteScripted();
if (spriteType == NULL)
spriteType = engine->GetObjectTypeByName("Sprite");
engine->NotifyGarbageCollectorOfNewObject(obj, spriteType);
return obj;
}
this happens whenever I use that object type as a member property of a complete angelscript class (a class not declared in c++). However, i dont have a problem when I use a c++ defined class in a limited scope such as 'Texture' in setSpriteWithName:
(angelscript code; I dont have problems with Texture but I do have leaks with Sprite)
class RenderComponenet : Component
{
Sprite sprite;
void setSpriteWithName(string name) {
Texture texture(name);
sprite.setTexture(@texture);
}
}
If anyone can see that I'm missing anything please let me know.
Thank you.