Re: A possible sound loading bug
Status: Alpha
Brought to you by:
cwalther
|
From: Christian W. <cwa...@gm...> - 2010-12-12 09:34:21
|
> By the way, what exactly happens if I load a sound into a global > variable, play it, then re-define the global variable again to load > a different sound? Does it flush the old sound? Or does it stay in > memory? Becouse I now realize that using my current function, the > sound seems to stay in memory even after the scheduled function re- > iterates and changes what sound the variable corrosponds to. This > leads to a slow increase in memory use, about two megs per minute in > my case. Any way I can avoid this, other then pre-loading all the > sounds first in node.lua? The sound stays in memory until Lua garbage-collects it. See the Lua manual for how to control garbage collection, if you need to. Lua only sees a small structure for every sound object (44 bytes if I counted correctly), it doesn't know about the associated OpenAL and Vorbis data (including buffered audio data, which is the whole sound if it's shorter than 10 seconds, or two streaming buffers of 172 KB for longer ones), so total memory usage per sound object (and accordingly total memory reclamation when the object is collected) is higher than Lua thinks. -Christian |