Having a n00b moment... Disposing of Audio in storyboard

So I’m sitting here merrily going along and at the top of a storyboard scene file,\
I happily do:

someSound = audio.loadSound(“pathto/sound.mp3”)

and later on, I will use audio.play to play said sound.

My scene exits, and I’m when I’m heading to my next scene, I execute:

timer.performWithDelay(1000, function() storyboard.removeAll() end)

to blow away any scenes that I still have. Memory is precious and I can’t wait on low memory events to clean up these graphic heavy scenes.

I have been running on the impression that my audio assets are being disposed of when this removeAll() fires. I was also under the impression that my sprite sheets, courtesy of sprite_loq were graciously being freed up as well.

While tracking down some bizarre behavior and odd crashes, I decided to watch my memory usage in Instruments and low-and-behold I’m leaking badly. Now since I know storyboard is cleaning up my images neatly for me, and my animations are inserted into group, they should be getting cleaned up too, which leaves me with Audio and sprite Factories (from sprite_loq) hanging around.

My question, is do I need to dispose of these assets by hand or is storyboard.removeAll() doing what I think it should? These are big leaks, not the garden variety Lua memory leaks. I’m heading into the Leaks memory profiler to see if it gives me any more info.

What say ye? Am I being a n00b? Are my other storyboard apps being problematic too?

Thanks
Rob

PS. Please do not move this to the sprite_loq forum, it’s a storyboard question. You can move it to the storyboard forum, its where I tried to post it, but in the required forum drop down above, I can’t choose storyboard… [import]uid: 19626 topic_id: 30350 reply_id: 330350[/import]

Let me take a stab at that. It would appear you are responsible for also cleaning up any sounds. Just make sure they are stopped before you try and dispose of the audio.

[import]uid: 19626 topic_id: 30350 reply_id: 121590[/import]

Hey Rob @robmiracle, I remove all references to imageSheet (after removing any display objects that use the imageSheet) as well as some display groups and spriteFactory in exitScene, like so:

function scene:exitScene()  
 display.remove( myButton ); myButton = nil;  
 btnSheet = nil;  
 myDisplayGroup = nil;  
 spriteFactory:dispose(); spriteFactory = nil;  
end  

I haven’t incorporated any sound assets to my current project that uses storyboard, so I haven’t investigated how it should be handled, but doing the manual removal/nil’ing out as noted above appears to keep the texture memory under control for me.

Naomi

Edit: Hmmm… I’m actually not sure if I should be manually nil’ing out some of the display groups. (I don’t remove all of them, but a select few, but it looks like I may need to take a closer look at why I’m removing them there… I might’ve already took care of them elsewhere. Good thing you got me looking at it.)

Edit2: Oh, I got it. I have a couple of display groups that holds number of display objects that use imageSheets. So… as part of removing these display objects, then nil’ing out the imageSheets, I’m nil’ing out the display groups too. May be not entirely necessary, but couldn’t hurt, I suppose. [import]uid: 67217 topic_id: 30350 reply_id: 121596[/import]

Let me take a stab at that. It would appear you are responsible for also cleaning up any sounds. Just make sure they are stopped before you try and dispose of the audio.

[import]uid: 19626 topic_id: 30350 reply_id: 121590[/import]

Hey Rob @robmiracle, I remove all references to imageSheet (after removing any display objects that use the imageSheet) as well as some display groups and spriteFactory in exitScene, like so:

function scene:exitScene()  
 display.remove( myButton ); myButton = nil;  
 btnSheet = nil;  
 myDisplayGroup = nil;  
 spriteFactory:dispose(); spriteFactory = nil;  
end  

I haven’t incorporated any sound assets to my current project that uses storyboard, so I haven’t investigated how it should be handled, but doing the manual removal/nil’ing out as noted above appears to keep the texture memory under control for me.

Naomi

Edit: Hmmm… I’m actually not sure if I should be manually nil’ing out some of the display groups. (I don’t remove all of them, but a select few, but it looks like I may need to take a closer look at why I’m removing them there… I might’ve already took care of them elsewhere. Good thing you got me looking at it.)

Edit2: Oh, I got it. I have a couple of display groups that holds number of display objects that use imageSheets. So… as part of removing these display objects, then nil’ing out the imageSheets, I’m nil’ing out the display groups too. May be not entirely necessary, but couldn’t hurt, I suppose. [import]uid: 67217 topic_id: 30350 reply_id: 121596[/import]