Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

izackp

Member Since 13 Jan 2013
Offline Last Active May 11 2013 08:59 AM

Posts I've Made

In Topic: Need help tracking memory leak

05 March 2013 - 01:32 PM

Well I'm glad I'm making progress and understanding angelscript more.  That code brings the ERRs down by 1 though



 (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 'Sprite', 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

 

However, I will figure it out.. I think I might just rebuild a minimal project to replicate the problem and try to isolate it. In situations like this I would normally breakpoint Release and AddRef and see which is being called when it isn't supposed to be called, but theres so much I don't know about the engine for me to dig through it.. Hopefully I figure this out soon xD


In Topic: Need help tracking memory leak

05 March 2013 - 12:29 PM

Not really the dictionary object just resides in a Testcomponent class which is just a container of class members and does nothing atm.

Sprite registers the proper behaviors. It does implement enum references, but it doesn't hold any references as of yet.


It really weird because the RenderComponent destructor gets called, but I still get the error.

This is the only thing angelscript script code that I run:

asIScriptModule* mod = builder.GetModule();
int testTypeId = mod->GetTypeIdByDecl("TestComponent");
asIObjectType *type = mod->GetObjectTypeByName("TestComponent");
testTypeId = type->GetTypeId();
asIScriptObject* objLogicComp = static_cast<asIScriptObject *>(engine->CreateScriptObject(testTypeId));
engine->NotifyGarbageCollectorOfNewObject(objLogicComp, type);
std::cout << "Ref Count: " << objLogicComp->Release() << std::endl;
std::cout << "Ref Count: " << objLogicComp->Release() << std::endl;
engine->GarbageCollect(asGC_FULL_CYCLE | asGC_DETECT_GARBAGE | asGC_DESTROY_GARBAGE);

 

 

TestComponent is just an empty class with a Render Component inside of it.

 

So the destructor of both TestComponent and RenderComponent gets called . Yet I still get these errors in my logs:

add - 2 - instanceId:1 - Sprite
add - 3 - instanceId:1 - Sprite
rel - 2 - instanceId:1
RenderComp Create
add - 2 - instanceId:2 - RenderComponent
add - 3 - instanceId:2 - RenderComponent
rel - 2 - instanceId:2
TestComp Create
rel - 1 - instanceId:2 //This release seems unusual
Ref Count: 2
Ref Count: 1
TestComp Destroy
RenderComp Destroy
//Sprite does not get destroyed
//Shutdown Engine
(0, 0) : ERR : GC cannot free an object of type 'TestComponent', it is kept alive by the application
(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 'Sprite', it is kept alive by the application
rel - 1 - instanceId:1
(0, 0) : ERR : GC cannot free an object of type '_builtin_objecttype_', it is kept alive by the application

 

 


In Topic: What's everyone doing with Angelscript!

04 March 2013 - 07:38 AM

I'm using it as the scripting language for my 2d game engine. 


In Topic: Register object behavior with pointer to instance function

01 March 2013 - 06:11 AM

Sort of... I ended up hacking it in by adding an extra parameter to the registerObjectBehavior function so now I can do this:
 

void SpriteScripted::registerAS(asIScriptEngine* engine, ScriptObjectCreationCache& creationCache) {
    int r;
    static const char* const strComponent = "Sprite";
    r = engine->RegisterObjectType(strComponent, sizeof(SpriteScripted), asOBJ_REF | asOBJ_GC); assert(r >= 0);
    r = engine->RegisterObjectBehaviour(strComponent, asBEHAVE_FACTORY, "Sprite@ f()", asMETHOD(ScriptObjectCreationCache, SSFactory), asCALL_THISCALL_ASGLOBAL, &creationCache); assert( r >= 0 );
    ....
}

 

 

it seems to work but I still have yet to run the angel script unit tests.


In Topic: what does offset point to in GetProperty

24 February 2013 - 06:53 AM

Awesome I didn't even see that function. Thanks.


PARTNERS