Hello all,
I had a question regarding removing objects at the end of a transition and if / how those objects are released from memory. The function below seems to add another 2-3kb of memUsage every time one of these new animated objects are created (texture memory is holding steady). The memUsage never goes down as the objects are removed.
local function newEnergy()
-- spriteSheets located in a table earlier
local energy1set = sprite.newSpriteSet(spriteSheets["energy1"], 1, 9)
sprite.add(energy1set, "animateenergy", 1, 9, 750, 0 )
local function disperse(self)
-- Moves an energyball graphic a given distance and removes it after 3 seconds
self.transition = tnt:newTransition(self, {x = self.x + math.random(-400,400), y = self.y - 400, time = 3000,
onComplete = function() self:removeSelf() self = nil end })
end
local energy = sprite.newSprite(energy1set)
energy.x = crystal2.x
energy.y = crystal2.y
energy:prepare("animateenergy")
energy:play()
rearLayer:insert(energy)
disperse(energy)
return energy
end
local energyTimer = tnt:newTimer(1500, newEnergy, 0)
Visually, this is working perfectly. I’m concerned about the creeping memory, however. I understand that I’m spawning these objects in a manner in which I lose the handle once they’re created. But I assumed it was fine since they are removed via a self-contained function. Am I incorrect? Is there a better way to do this?
-Brandon [import]uid: 136211 topic_id: 31476 reply_id: 331476[/import]
[import]uid: 74338 topic_id: 31476 reply_id: 125832[/import]