Page 1 of 1

Can we free those memory?

Posted: Sat Sep 27, 2008 5:18 am
by armzajetset
I'm using IrrKlang. Everything seems fine when I play the sound. But there's one thing. The number of memory usage rocket up everytime the sound play.

Code: Select all

sp = Sfx->play2D(music);
Just load and play it. I've read something about "stop" but how to use it ?

This problem is affected to mesh file. When I load my level on the scene and change map (delete old scene) the memory usage doesn't decrease. Also AVI file when I play it for second time and memory usage is rising up! Am I do anything wrong with those pointer ?

This problem occur even in IrrKlang Example itself.

This is my full class of sound effect.

Code: Select all

class SoundEffect
{
	
public:
	ISoundSource* music;
	ISound* sp;
	bool is_stop;

	char *files;
	float Volume;
	// Set Sound
	void Load(char file[50]){
		files=file;
		music = Sfx->getSoundSource(file);
		Volume=1.0f;
	}
	void Del(){
		sp->stop();
	}

	// Stop Sound All
	void Stop(){
		Sfx->stopAllSounds();
	}

	// Play Sound
	void Play(){
		sp = Sfx->play2D(music);
		Sfx->setSoundVolume(Volume);
	}

	// Set Volume take 0-100 
	void SetVol(int rate){
		Volume=rate/100;
	}
};
Maybe just like

fx1.load(somefile);
fx1.play();
fx1.del()

????

Posted: Sat Sep 27, 2008 1:26 pm
by rogerborg
IrrKlang question? IrrKlang forums.

I've made several attempts to compose an answer to this, but I'm not entirely sure what the problem is.

ISoundEngine::play2D() shouldn't be returning an ISound* (so your Del() method will crash). If it is returning an ISound*, then that's a bug in IrrKlang, at least according to its own API documentation. If it is returning an ISound*, then you must (again, according to its API) drop() it when you're done with it.

ISoundEngine::getSoundSource() apparently shouldn't be loading the raw resource multiple times, and shouldn't be dropped() but again, I'm not entirely clear on what's going on internally.

Posted: Sun Sep 28, 2008 5:17 am
by armzajetset
Sorry I'll explain this over again (sry again about my language. I'm not native speaker.) Here's example. When I play something like click sound (on my GUI, you know when the curser move or something like that.) First memory usage is at 4000 and then I move my cursor again it increase to 4004 and 4008 and so on ...

That may cause the crash when I move my cursor in huge number of times. My question is " is there a way to load sound into buffer just once and play it back again and again with no memory usage increasing ? "

Posted: Sun Sep 28, 2008 7:32 am
by rogerborg
rogerborg wrote:IrrKlang question? IrrKlang forums.

Posted: Sun Sep 28, 2008 9:16 am
by armzajetset
rogerborg wrote:I've made several attempts to compose an answer to this, but I'm not entirely sure what the problem is.
rogerberg wrote: but again, I'm not entirely clear on what's going on internally.

Anyway thanks!!

Posted: Sun Sep 28, 2008 1:20 pm
by rogerborg
I notice that you still haven't asked your question in the IrrKlang forum. If you're having trouble posting there, then you can contact Niko directly to let him know that there's a problem with the Ambiera forums.

Posted: Sun Sep 28, 2008 1:36 pm
by armzajetset
I didn't ask because there's a thread which asking the same question. So I've put my queastion in that thread (once again).

http://www.ambiera.at/forum/Blah.pl?m-1221776969/