Sprite memory leak (not texture mem)?

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]

I had the issue when removing an image then reloading the image memory would go up but I switch to a spritesheet and spritegrabber and it fix it [import]uid: 7911 topic_id: 16971 reply_id: 63638[/import]

@jstrahan – I’ve already mentioned this is not a texture memory leak. It’s a lua memory leak noted by the “instruments” tool.

Also, I chose to avoid Sprite Grabber. I’m using 1 image “sheet” with the native CoronaSDK spritesheet functionality.

[import]uid: 59138 topic_id: 16971 reply_id: 63640[/import]

mine wasn’t texture memory either it was lua memory
my texture. memory was releasing and reallocating correctly but lua memory was going up
spritegrabber can handle all sprites on one sheet it’s all in the way you name the images [import]uid: 7911 topic_id: 16971 reply_id: 63643[/import]

I appreciate the suggestion… I’ll look more into the SpriteGrabber as an alternative.

However, I am still curious to whether I’m missing something, or if this is a known Corona SDK bug. [import]uid: 59138 topic_id: 16971 reply_id: 63650[/import]

I use spriteloq and I notice that it does a sprite dispose on a small delay. There is a note that this is because of a Corona bug, but no more details are given.

If you’re willing to try some more experimentation, try putting a delay between the sprite pause and dispose. [import]uid: 67839 topic_id: 16971 reply_id: 63655[/import]

Hi elbowroomapps,
I gave it a try with no luck. The leak is still present. [import]uid: 59138 topic_id: 16971 reply_id: 63678[/import]

Nothing here stands out to me but if you are having persistent problems with your code it might be worth checking out http://www.anscamobile.com/corona/support/ [import]uid: 52491 topic_id: 16971 reply_id: 63720[/import]

I believe that is a little overkill as I’ve already done the long tedious part of hunting down the leak to the sprite. 100% sure. I’ve turned a large (finished) project into the simple basics I’ve posted above. Not really much else to it.

Anyway, My goal of this thread to see what the community said before I took any action (like reporting a bug). I definitely not here to yell “FIX IT FOR ME!” :). jstrahan has stated he has had a similar problem… perhaps it’s a bug with the SDK? What an expensive way to find that out.

[import]uid: 59138 topic_id: 16971 reply_id: 63868[/import]

Update: I went the extra mile and created a new project with a simple sprite(instead of using a trimmed version of my existing project) to further prove that the problem is isolated to sprite and not something else in my project.

The simple act of creating a sprite causes a lua memory leak. So that settles it: I’ll submit a bug report.

[import]uid: 59138 topic_id: 16971 reply_id: 63882[/import]

Hi,

what’s the case number?
I’m experiencing the same issue.

[import]uid: 109453 topic_id: 16971 reply_id: 105692[/import]

Guys has this bug been submitted what was the result?
[import]uid: 121261 topic_id: 16971 reply_id: 112425[/import]

Peach I reported this bug.

(Case 15095) sprite.newSprite memory leak

It is quite an important issue and especially in our case, we are unable to release our game with this still outstanding.

The bug is 35days old and as yet no response?

Our game is not yet ready for release but still this does not fill us with confidence and we are seriously considering an alternative platform.

Any way you can help?

Best,
dalste [import]uid: 121261 topic_id: 16971 reply_id: 116881[/import]

Hey Dalste,

Looking at this it actually looks like you got an email about this today which included a sample showing you how you needed to nil things out?

Please let me know if you didn’t receive this - I will make sure it is resent.

Peach :slight_smile: [import]uid: 52491 topic_id: 16971 reply_id: 116989[/import]

Hey Peach,

Yes I did get a reply yesterday. I did an initial test, but I need to test further to verify. I was unaware of the delayed garbage collection functionality in lua and this may well be what is giving the impression of a problem here.

I want to ensure that the cleaning of the imported lua file is not masking any memory leaks that may occur via repeated sprite generation from a single import.

I still need to verify, but thank you and the team for responding so quickly to my follow up enquiries.
Ill reply to the email shortly.
Thanks again.

dalste [import]uid: 121261 topic_id: 16971 reply_id: 116992[/import]

Glad to hear it - hope you find you are now able to move forward with your project :slight_smile:

Peach [import]uid: 52491 topic_id: 16971 reply_id: 117167[/import]