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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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;

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

@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.

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

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.

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.

Hi elbowroomapps,
I gave it a try with no luck. The leak is still present.

views:1529 update:2011/10/28 9:34:19
corona forums © 2003-2011