HTML memory leak?

Hi, I’m currently working on a small webapp which uses a lot of sound. Unfortunately after I load a few sounds (each one is between 500Ko and 2Mo) chrome tells me that my app is using to much memory. I tried few ways to load the sound (URLloader, assets with embed set to false) and my app always eventually make chrome crash.
I currently use this code to load my sounds :

soundChannel.stop();
soundChannel = null;
soundChannel = new SoundChannel();
audio.close();
audio = null;
audio = new Sound();
Assets.cache.clear();
Assets.cache.setSound(soundName, Assets.getSound(“embedaudio/” + soundName+".ogg", false));
audio = Assets.cache.getSound(‘soundName’);
soundChannel = audio.play();
soundChannel.soundTransform = effects;

Am I doing something wrong (it really seems I did ^^) ?
Hope you’ll be able to help me ! This issue is really driving me crazy right now !

It should work like this:

var sound = Assets.getSound ("soundName");
soundChannel = audio.play ();
soundChannel.soundTransform = effects;

Assets handles the cache for you, however, on HTML5 we may preload all the sound (or other assets) automatically.

Perhaps you should look at your output folder for HTML5. Are all the files you intended to load for HTML5 being copied, or are additional files you didn’t intend (perhaps in an asset path by accident) being loaded as well, such as PSDs, FLAs or other source documents?

I’ve never run out of RAM in the browser with an OpenFL project that I recall

Thanks for your answer. Anyway this doesn’t seems to work.
I have to load 40 files, for a total weight of nearly 45 Mo, is it too much ?
I tried this with .mp3 and .ogg.
With .mp3 the sounds are not playing, is there a particular setting that I need to use (bitrate, frequency) ? They seems to be loaded because I doesn’t get any error message.
With the.ogg I ended up with a huge memory consumption (almost 2.5Go).
I’m really lost here.

MP3 only works on flash due to licensing issues (it’s under patent or license or something so if you include an mp3 decoder in your game you have to pay a lot of money for it, with Adobe Flash I think their mp3 encoder is covered because Adobe has prepaid that sort of license and the Flash EULA protects you as a developer, or something like that)

.ogg only works on Chrome, you need something like .wav or preferably a .m4a (SoundJS doesn’t like .wav files very much) if you want to play a sound on Firefox/IE (and Chrome and Safari). That’s not to say there isn’t some kind of a problem (/ problems) with OpenFL though…

Hi,

thanks for your answers, I used .ogg and it work well in firefox and opera. But in chrome the garbage collection doesn’t seems to work ! I got a lot of sounds to load so the memory consumption grows increasingly during time…I don’t understand why opera and firefox took care of the GC while chrome doesn’t care.

Sorry, I should have been more precise and say that .ogg files, like .wav files, might cause some loading problems with soundJS on Firefox (and possibly elsewhere at times). It’s supposed to work, but it doesn’t, not reliably. As for your problem, you can try playing the sounds with howler instead.

Please let me know if (perhaps?) a newer Sound.js release works better. I used Howler before, but had issues with music, looping, a few things that Sound.js did better. Long-term, though, it would be nice to have Howler-like code integrated into Lime directly