Discussion:
[Audiere-users] Freeing loaded sounds / memory leak woes
Jacky J
2006-11-02 07:44:25 UTC
Permalink
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
Matt Campbell
2006-11-02 15:04:58 UTC
Permalink
Hello:

It looks like you're doing it right; you're using a smart pointer, so
the memory should be freed as soon as that pointer goes out of scope.
Which device implementation are you using, and which version of
Audiere? Thanks.
--
Matt Campbell
Lead Programmer
Serotek Corporation
www.freedombox.info
"The Accessibility Anywhere People"
Jacky J
2006-11-03 06:05:08 UTC
Permalink
OS is Windows XP, Visual Express C++ is the compiler, Audiere version 1.9.4.

I've made a simple project that demonstrates the problem:
http://www.cs.utah.edu/~witkowsk/files/audtest.zip

Note you'll have to set the working directory to "working" to run it from
the IDE. You can also run the prebuilt .exe from the working folder.

I've run it through debugger and it seems like the number of calls to
unref() matches up with ref(), so i don't know why it won't release the
memory.

Thanks
Post by Matt Campbell
It looks like you're doing it right; you're using a smart pointer, so
the memory should be freed as soon as that pointer goes out of scope.
Which device implementation are you using, and which version of
Audiere? Thanks.
--
Matt Campbell
Lead Programmer
Serotek Corporation
www.freedombox.info
"The Accessibility Anywhere People"
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job
easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Audiere-users mailing list
https://lists.sourceforge.net/lists/listinfo/audiere-users
Loading...