Could you please explain why the following code leaks? You can test it just as it is in the iPad simulator (no config.lua or build.settings needed). It seems to run stable around a minute or so (on my machine), but after that CPU usage raises rapidly and it will crash. Curious thing is, if you disable the bubbles or the box it can run stable at least for 3 minutes(didn’t test longer). It’s so weird. Please help, this is driving me mad! It’s good to test this with Activity Monitor(Mac) open so you can observe the CPU usage. Please let it run up to 2 minutes to see it crash. I tested this with Build 2014.2185.
[lua]
local box = display.newRect(600,680,50,50)
– Box Movement
local function RotateBox(_object)
local function RotateBack()
transition.to(_object,{delta=true, time=3000, rotation=30, onComplete=RotateBox})
end
transition.to(_object,{delta=true, time=3000, rotation=-30, onComplete=RotateBack})
end
RotateBox(box)
– Bubble Float Left-Right
local function FloatLeft(_object)
local function FloatRight()
_object.transition = transition.to(_object, {time=1000, delta=true, x = 30, onComplete = FloatLeft})
end
_object.transition = transition.to(_object, {time=1000, delta=true, x = -30, onComplete = FloatRight})
end
– Bubble Float Up
local function FloatUp (_object)
local function RemoveMe()
if _object.transition ~= nil then
transition.cancel(_object.transition)
end
display.remove(_object)
_object = nil
end
transition.to(_object, {time = math.random(2500,5000), y = 100, onComplete = RemoveMe})
end
local function CreateBubbles()
local bubble = display.newCircle(math.random(50,500),700,8)
FloatLeft(bubble)
FloatUp(bubble)
print("Bubble count: " … display.getCurrentStage().numChildren)
end
timer.performWithDelay(1,CreateBubbles,0)
timer.performWithDelay(1,CreateBubbles,0)
timer.performWithDelay(1,CreateBubbles,0)
[/lua]