views:

91

answers:

1

I load some .wav files in my iPhone app like this:

SoundEngine_LoadLoopingEffect([[bundle pathForResource:@"loop" ofType:@"wav"] UTF8String], NULL, NULL, &MySounds[Loop]);

SoundEngine_LoadEffect([[bundle pathForResource:@"intro" ofType:@"wav"] UTF8String], &MySounds[IntroMusic]);

The "intro.wav" file takes up some space (approx 2 meg). I play it only once when the app starts up. I'd like to free-up or release the memory allocated for this .wav file. How can I do this?

Does:

SoundEngine_Teardown();

release all the memory I've allocated by calling SoundEngine_LoadEffect?

+1  A: 

It should remove references to it - but because you have not called 'alloc' or 'init' on these objects yourself, you don't 'own' them (that's the golden rule of ObjC memory management)

They will be passed to the controlling thread's autorelease pool, and released as necessary. In other words, it's not something yo have to worry about.

Chaos
Hey thanks for the response :-) What if I want to actually load, play, unload .wav files? (the files might be big and I don't want to use memory when I don't need to)
MrDatabase
I'd use libsndfile - a lot easier than trying to juggle the inbuilt stuff, especially for .wav
Chaos