TLDR; in NWJS, when playing the same set of sounds over and over again over a period of time, used memory will increase (potentially infinitely) until it affects performance.
The following pertains to EXE's exported with NWJS from Construct 2. C2 and NWJS are updated to the latest versions.
When playing audio, it appears that some sounds get "stuck" in memory and stack up over time. After a long time in a complex game with lots of audio, this results in slowing down the framerate.
I've tested with sound files that are (A) stored in the exe, and (B) stored externally. For external audio, you can use Audio - Unload All to bring memory and framerate back to normal, but using Audio - Unload by name for each sound file does not help.
I've created a test capx with internal sound files and buttons which manually preload and unload external sound files. There are two buttons which toggle randomly playing these sounds extremely rapidly. One only plays internal sounds, the other only plays external sounds.
In the following tests I took note of the Memory in MB via Windows Task Manager. There are inconsistencies sometimes when running these tests, but my findings in general are listed below:
1) CONTROL - Run the EXE and do nothing for 5 minutes.
Results: Memory starts at 75mb, after 5 minutes memory ends up at 73mb.
2) Run the EXE, Preload external sounds, Play external sounds rapidly for 5 minutes.
Results: Memory starts at 72mb, after 5 minutes memory ends up at 92mb.
Addl notes: Unloading sounds manually (by name) does not decrease memory usage. Unloading ALL sounds DOES decrease memory usage.
3) Run the EXE, Play internal sounds rapidly for 5 minutes.
Results: Memory starts at 72mb, after 5 minutes memory ends up at 94mb.
Addl notes: Unload Sounds (by name) and Unload All Sounds both have no effect on memory.
Letting the test run longer than 5 minutes shows the memory increase further, I did not see a maximum in my testing.
This seems minor when looking at this small test EXE, but with a big project with hundreds of sounds effects and music, this becomes a problem where memory can increase in the hundreds of megabytes over 10 minutes of play and negatively affect framerate. In my actual game, memory increased from 200mb to 2200mb over the course of 20 minutes of play, and framerate dropped to 30fps. Using Unload All Sounds fixes the problem temporarily, but I cannot use that during normal play for game audio quality reasons, and Unload Sounds (by name) has no beneficial effect to memory or framerate.
Capx and audio files:
drive.google.com/file/d/1iGf_hWjeu6EfqG3XIihX7dJycuROU71_/view
Put the audio files in a folder titled "data" in the same folder as the exported EXE. Let me know if you have any questions, and thank you for your time.
Edit: I did some additional testing. It appears that if you Preload external sounds, toggle them on for a few minutes until memory increases noticeably, then toggle the sounds OFF and wait a few seconds, then neither of the Unload commands do anything for the memory. So it appears that the Unload commands only affect currently playing sound files?
Note: If you'd like to more quickly see results in your test, add "Repeat x times" to the code as shown in this linked image:
drive.google.com/file/d/1wCN1RGmTJJ-wyAY9le1WU49ipEByRr5p/view