I just upgraded to the latest version of Corona SDK (CoronaSDK_2011.484)
After this it seams that the garbage collection doesn’t work as it causes the simulator to crash.
This is what the Terminal says:
1328 Bus error "$path/Corona Simulator.app/Contents/MacOS/Corona Simulator" $\*
logout
This is what causes the crash:
[lua]collectgarbage(“collect”);[/lua]
The collectgarbage call comes from within a function that removes an object upon collision.
[lua]function bump:pop()
–Remove the object
self:removeSelf();
self = nil;
collectgarbage(“collect”);
end
function bump:collision(e)
if(e.phase == “ended”) then
–If a bump collides with the ball
if(e.other.type == “ball”) then
self:pop();
end
end
end
bump:addEventListener(“collision”, bump);[/lua]
Is this a bug? [import]uid: 41041 topic_id: 9036 reply_id: 309036[/import]
Remove the eventlistener of that object before you delete it. [import]uid: 5712 topic_id: 9036 reply_id: 32931[/import]
That doesn’t seems to work. It just gives me another Bus Error
398 Bus error "$path/Corona Simulator.app/Contents/MacOS/Corona Simulator" $\*
Logout
This would be how it looks now:
[lua]self:removeEventListener(“collision”, bump);
self:removeSelf();
self = nil;
collectgarbage(“collect”);[/lua]
I don’t know if this is a bug or if I’m just doing something wrong. However I didn’t have this problem in the previous version. [import]uid: 41041 topic_id: 9036 reply_id: 32955[/import]
Mmh, if I remember correctly, they have changed the way removeself works. I don’t use it, so I have not run into that problem. [import]uid: 5712 topic_id: 9036 reply_id: 32957[/import]
As I understand this change was prior to Beta 8 of the Corona 2.0 SDK so it shouldn’t affekt this update.
I have moved the collision event listener to another object leaving just the bump:pop() function. Still it crashes when calling the garbage collection. If I remove it, the simulator doesn’t crash. [import]uid: 41041 topic_id: 9036 reply_id: 32966[/import]
The response in this thread also solves this issue: [import]uid: 41041 topic_id: 9036 reply_id: 33947[/import]