开发者

Must I release the OpenAL context here?

开发者 https://www.devze.com 2023-03-17 15:28 出处:网络
When setting up OpenAL, the Leaks Instruments tells me that I am leaking alContext here: alDevice = alcOpenDevice(NULL);

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消