I spent some time to track down a memory leak that i’m experiencing. After hours and hours of eliminating elements of my code, I’ve narrowed it down to my animated sprite. There is no texture memory leak-- This leak is observed using the “Instruments” tool.
I’m 100% sure it is sprite related.(I replaced my sprite with a simple rectangle and the leak disappeared.)
Anyone experience this? any suggestions? I’m not a fan of posting code but, there really isn’t anything that stands out.
Big thanks in advance!
My stripped player class pasted below… cleanup func is called when i change scenes.
[code]
local creator = {};
function creator.new( params)
local physics = require “physics”
physics.setGravity( 0, 17)
local gx, gy = physics.getGravity();
local sprite = require (“sprite”);
local this = {};
local sheet1;
if display.contentScaleX == .5 then --iPhone 4
sheet1 = sprite.newSpriteSheet( “playerColors_2x.png”, 100, 100 )
else – iPhone 3G, 3Gs
sheet1 = sprite.newSpriteSheet( “playerColors2.png”, 50, 50)
end
local spriteSet1 = sprite.newSpriteSet(sheet1, 1, 24)
sprite.add( spriteSet1, “R_run”, 1, 3, 400, 0)
sprite.add( spriteSet1, “R_jump”, 4, 3, 200, 1 )
sprite.add( spriteSet1, “R_land”, 7, 2, 150, 1 )
sprite.add( spriteSet1, “G_run”, 9, 3, 400, 0 )
sprite.add( spriteSet1, “G_jump”, 12, 3, 200, 1 )
sprite.add( spriteSet1, “G_land”, 15, 2, 150, 1 )
sprite.add( spriteSet1, “B_run”, 17, 3, 400, 0 )
sprite.add( spriteSet1, “B_jump”, 20, 3, 200, 1 )
sprite.add( spriteSet1, “B_land”, 23, 2, 150, 1 )
this = sprite.newSprite( spriteSet1 );
if display.contentScaleX == .5 then
this.xScale = .5; this.yScale = .5
end
physics.addBody(this, { density = 0.5, friction = 0.00, bounce = 0.0, radius = 25 })
this.isFixedRotation = true
this:prepare(“R_run”);
this:play();
function this.cleanup()
this:pause();
sheet1:dispose()
sheet1=nil;
end
return this;
end
return creator;
[/code] [import]uid: 59138 topic_id: 16971 reply_id: 316971[/import]
[import]uid: 52491 topic_id: 16971 reply_id: 116989[/import]