Memory leak with sound?

Started by Kweepa, Thu 06/05/2010 20:08:00

Previous topic - Next topic

Kweepa

My game keeps using more and more memory (the private working set in Task Manager), unless I disable sound from winsetup.
Is this a known bug or a problem with my machine or scripting?
Thanks!

Steve

[EDIT] This is with 3.2.0.102 (Final4)
Still waiting for Purity of the Surf II

Alan v.Drake

Confirmed for memory leak.
Even the earlier 3.2.0.102 (Final 3) seems to have the same problem.

- Alan




xenogia

Which could definetly give a reason to why there is sound stutters.

Dualnames

Quote from: Xenogia on Thu 06/05/2010 22:02:51
Which could definetly give a reason to why there is sound stutters.

Which has been there since 2.72. I never kind of noticed the memory leak ever. :-\
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Kweepa

Quote from: Xenogia on Thu 06/05/2010 22:02:51
Which could definetly give a reason to why there is sound stutters.
Let's not jump to conclusions!
These are probably unrelated.
Still waiting for Purity of the Surf II

Alan v.Drake

Yeah, the stutter usually happens those times the audio buffer isn't being cleared when the engine isn't fast enough to fill it... uhm, isn't audio playback handled in a different thread to avoid this ?

Wyz

Technically a buffer should never cause memory leaks. A buffer is a preallocated space in the memory and when they overflow they cause segmentation errors and not leaks. I'm afraid the problem is a bit more complicated.
What kind of sound files(file format, version etc) are you using?
Life is like an adventure without the pixel hunts.

xenogia

It is all good CJ is looking into the sound stutters anyhow.. and if you want to know I'm using OGG and the latest build of ags.

Pumaman

Quote from: SteveMcCrea on Thu 06/05/2010 20:08:00
My game keeps using more and more memory (the private working set in Task Manager), unless I disable sound from winsetup.

Thanks for reporting this. I think I have identified the cause of the problem; could you please download this patched ACWIN.EXE and replace the one in your AGS folder with it. Then, see if you still get the memory leak:
http://www.adventuregamestudio.co.uk/acwin.zip

Alan v.Drake

Quote from: Pumaman on Sun 09/05/2010 16:53:18
Quote from: SteveMcCrea on Thu 06/05/2010 20:08:00
My game keeps using more and more memory (the private working set in Task Manager), unless I disable sound from winsetup.

Thanks for reporting this. I think I have identified the cause of the problem; could you please download this patched ACWIN.EXE and replace the one in your AGS folder with it. Then, see if you still get the memory leak:
http://www.adventuregamestudio.co.uk/acwin.zip


It seems to work just fine, I havent noticed any leak with it.

- Alan

Kweepa

That seems to have done it - thanks Chris!
Memory keeps growing until all effects have played once (I guess that's what's happening), then it stops.
Steve

PS Is it safe to distribute a game with this acwin compiled in?
Still waiting for Purity of the Surf II

xenogia

Might as well add this to my game as well, as after people pointing this out I did notice the memory leak.
Mine went up to 300mb use .. ouch

Alan v.Drake

#12
Hmm... on further testing with "No Digital Sound", there are now null pointer exceptions when audio is .Play()ed... but not always...

EDIT: I realized the error comes when trying to access the channel returned by the .Play() function, the same things happens also with sounds enabled, while skipping a cutscene that contains a code such as follows:
Code: ags

	StartCutscene(eSkipESCOrRightButton);
	player.Walk(320, 140, eBlock);
	Wait(40);
	Wait(40);
	AudioChannel *channel = aDoorClose.Play();
	channel.Panning = 100;
	EndCutscene();

it says that "channel" is null, and it is. I can work around the problem with a "if (channel!=null) ..." .
Hope that helps fix the problem.

- Alan

EnterTheStory (aka tolworthy)

Quote from: Pumaman on Sun 09/05/2010 16:53:18please download this patched ACWIN.EXE and replace the one in your AGS folder with it. Then, see if you still get the memory leak:
http://www.adventuregamestudio.co.uk/acwin.zip

Should this be downloaded for all versions of 3.x? (Or maybe that's a really stupid question)

Kweepa

Quote from: Alan v.Drake on Mon 10/05/2010 09:16:10
EDIT: I realized the error comes when trying to access the channel returned by the .Play() function, the same things happens also with sounds enabled
<snip>
it says that "channel" is null, and it is. I can work around the problem with a "if (channel!=null) ..." .
I would imagine this happened before the patch, as you should always check that the returned channel is not null.
But given how likely this is to happen, it seems like AGS should return a dummy channel which can be queried to determine if the sound actually played.
Still waiting for Purity of the Surf II

Codex

I just wanted to report that the .exe replace fixed a major stuttering problem with my audio.

Thanks!

xenogia

Codex that has been there for ages I'm afraid.

Codex

Well, it must have been just upgrading to 3.2 then, thanks!

Pumaman

QuoteThat seems to have done it - thanks Chris!
Memory keeps growing until all effects have played once (I guess that's what's happening), then it stops.

PS Is it safe to distribute a game with this acwin compiled in

Glad to hear it! It should be safe to use that EXE, it is just Final 4 with that extra fix.
I'll roll it into the next release.

QuoteEDIT: I realized the error comes when trying to access the channel returned by the .Play() function, the same things happens also with sounds enabled, while skipping a cutscene that contains a code such as follows:

Yes, the value returned from Play() should always be checked to see if it is null. However, I do see Steve's point that this could be a major headache and maybe returning a dummy channel would be better.

QuoteShould this be downloaded for all versions of 3.x? (Or maybe that's a really stupid question)

No, it only affects 3.2. If you're using an earlier version, you don't need it.

SMF spam blocked by CleanTalk