Game Development Community

Stopping / starting music - memory leak?

by Keith Johnston · in Torque Game Engine · 12/16/2004 (1:33 pm) · 4 replies

I am using ogg files for music. I have two different music tracks that I need to switch between: "play" and "run". Here is how I'm doing this:

function startMusic()
{
	alxStop($PlayGui::runMusic);
	$PlayGui::playMusic=alxPlay(TTPlay_Music);      
}

function startRunMusic()
{
	alxStop($PlayGui::playMusic);
	$PlayGui::runMusic=alxPlay(TTRun_Music);      
}

When I call these functions repeatedly, there seems to be a constant increase in memory.

#1
12/20/2004 (1:49 pm)
I believe there have been some memory leaks related to streaming OGG audio sources.
#2
12/21/2004 (10:35 am)
You may want to check out Marcelo's sound update resource. I was using streaming ogg files for music, and this sorted out the memory leak problem for me.
#3
01/01/2005 (6:08 am)
Well I looked at that resource, and unfortuantely it is windows-only.

I used the memory leak resource to discover that it does not look like this is anything in Torque.

I think this is a problem in the OpenAL32.dll. I tried using the one from this site: http://developer.creative.com/articles/article.asp?cat=1&sbcat=31&top=38&aid=46

Using this version of the library, the music memory leak disappeared! However, the sound does not play with this version, just the music. Very odd.
#4
11/01/2008 (9:18 am)
This is an old thread but it helped me isolate a memory leak I was having. If anyone is interested, the easy fix is to call the console function OpenALInit() whenever you want to reset and free up the memory. For me, this was at the beginning of every mission before playing the new music. Hope that helps someone.