Jacky J
2006-11-02 07:44:25 UTC
Hi,
I have a wrapper class for sound that calls a LoadSound function. Device is
a AudioDevicePtr that is a private member of the class.
I'm having a problem with the sound files not being freed when they're "out
of scope".
I narrowed the problem down to this (a different, simplified version of the
LoadSound function)
int SoundClass::LoadSound(.....) {
audiere::OutputStreamPtr Data(audiere::OpenSound(Device, "test0.ogg",
false));
if (!Data) {
return 0;
}
return 1;
}
Since Data goes out of scope as soon as the function ends, it should free up
the memory that was allocated, right? I find that when i call this function
repeatedly, it nevers frees up the memory, causing a memory leak.
However, i did find that if reassigned Device everytime that function got
called, it would free up memory.
I am doing this right? What's the best way to free memory?
Thanks
I have a wrapper class for sound that calls a LoadSound function. Device is
a AudioDevicePtr that is a private member of the class.
I'm having a problem with the sound files not being freed when they're "out
of scope".
I narrowed the problem down to this (a different, simplified version of the
LoadSound function)
int SoundClass::LoadSound(.....) {
audiere::OutputStreamPtr Data(audiere::OpenSound(Device, "test0.ogg",
false));
if (!Data) {
return 0;
}
return 1;
}
Since Data goes out of scope as soon as the function ends, it should free up
the memory that was allocated, right? I find that when i call this function
repeatedly, it nevers frees up the memory, causing a memory leak.
However, i did find that if reassigned Device everytime that function got
called, it would free up memory.
I am doing this right? What's the best way to free memory?
Thanks