From: Eric W. <ewm...@gm...> - 2013-01-23 08:29:34
|
Sorry if some of you have already seen this, but I'm struggling with %newobject and %delobject. I can't tell if the problem is if I'm misusing and misunderstanding them or if there is an actual bug. My expectation is in garbage collected languages, the %delobject function should automatically be invoked when all references to an object are removed and the garbage collector kicks in. In my reduced test case, I have 2 C functions that load sound handles (malloc) and a function that deletes them. In my .i file, I declare them like so: %newobject ALmixer_LoadAll; %newobject ALmixer_LoadStream; %delobject ALmixer_FreeData; extern ALmixer_Data* ALmixer_LoadAll(const char* file_name); extern ALmixer_Data* ALmixer_LoadStream(const char* file_name); extern void ALmixer_FreeData(ALmixer_Data* almixer_data); I started with the JavaScriptCore generator but never saw anything get collected. So with the Lua generator, I repeated the same test and know I can force garbage collection by calling collectgarbage("collect"). Basically my test script is: sound = ALmixer.LoadAll("test.wav") sound = nil collectgarbage("collect") I expect my ALmixer.FreeData function to be called when the object is collected. My FreeData function prints a message to let me know if it was called. It is not called. Thanks, Eric -- Beginning iPhone Games Development http://playcontrol.net/iphonegamebook/ |