Release Memory After Audio Preload

0 favourites
  • 6 posts
From the Asset Store
Memory game, with 10 levels for you to have fun. Made in Construct3, template available for purchase.
  • I've noticed that while preloading audio files, memory usage tends to spike pretty high. The problem I'm having is that after all preloading is complete, the memory stays spiked. I thought construct dealt with memory on a layout-by-layout basis, but even after switching layouts the situation remains.

    I've tested this in preview, html5 export, and node-webkit. What's strange is that sometimes the memory will actually dip back down after preloads completed, but it seems to only happen randomly. Even with no event changes on my end.

    I should note that I'm preloading several songs but that shouldn't be much of an issue. I know it's not being executed the same way but here's an example of 12 3-minute audio files being loaded with html that only uses about 150m kevincennis.com/mix . When I try to load the same amount of tracks of approximately the same length, memory usage shoots up to 650m.

    I don't think it's a coding thing on my end but here's the capx file anyway - minus the audio for file size db.tt/JuVvP8yE . If what I'm experiencing isn't a bug, is there a workaround I can use to flush the memory somehow, but keep the audio files ready for playback? Thanks for any insight.

  • Browsers don't provide any feature to flush audio memory, so we cannot add one. Instead, they use garbage collection. If the memory use gets too high they will release things from memory. If it can fit in memory it will probably keep it there. So it's probably nothing to worry about.

  • Is there no way to force garbage collection through a plugin though Ashley?

    Ex. stackoverflow.com/questions/3034179/javascript-force-gc-collection-forcefully-free-object

  • Interesting, that's good to know. The problem is that I have even more files than in that example, and almost every time it tries to load, it crashes. Maybe it's using up memory so quickly that the browser can't dump it? Though, I've tried staggering loads as a test - waiting for one small-batch preload to finish and then start another - and that doesn't seem to help either.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Javascript provides no mechanism by which a garbage collection can be forced. The obvious thing to do seems to be: just don't preload anything apart from the handful of most latency-sensitive sound effects. In particular, you should not preload any music at all.

  • I hear that - wish I could. The project I'm working on is similar in idea to that mixer I linked to earlier, so basically everything is latency-sensitive. Unfortunately when I try to run it as Music and not Sound, things get pretty far out of sync. And when I just play them as Sound without preloading them first, the memory still jumps like crazy. In this scenario it also starts playing each channel when it finishing so the first track can be as far as a minute ahead of the final loading track. Still not sure what the best plan is yet but thanks for all the feedback!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)