Can we free those memory?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
armzajetset
Posts: 40
Joined: Tue Mar 13, 2007 9:23 am
Location: Thailand

Can we free those memory?

Post 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()

????
Image Irrlicht NewBie~*
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post 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.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
armzajetset
Posts: 40
Joined: Tue Mar 13, 2007 9:23 am
Location: Thailand

Post 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 ? "
Image Irrlicht NewBie~*
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

rogerborg wrote:IrrKlang question? IrrKlang forums.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
armzajetset
Posts: 40
Joined: Tue Mar 13, 2007 9:23 am
Location: Thailand

Post 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!!
Image Irrlicht NewBie~*
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post 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.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
armzajetset
Posts: 40
Joined: Tue Mar 13, 2007 9:23 am
Location: Thailand

Post 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/
Image Irrlicht NewBie~*
Post Reply