When setting up OpenAL, the Leaks Instruments tells me that I am leaking alContext here:
alDevice = alcOpenDevice(NULL);
if (!alDevice) {
return NO;
}
alContext = a开发者_开发问答lcCreateContext(alDevice, 0); // leaking!
if (!alContext) {
return NO;
}
BOOL success = alcMakeContextCurrent(alContext);
if (!success) {
return NO;
}
return YES;
Where and how should I release the alContext?
Here's how you would cleanup:
alcMakeContextCurrent(NULL);
alcDestroyContext(alContext);
alcCloseDevice(alDevice);
And you would just call these methods whenever you are done with the context... that depends on your application and how you are using it, but probably in a dealloc
somewhere.
精彩评论