aboutsummaryrefslogtreecommitdiffhomepage
path: root/applause.lua
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2016-01-12 14:52:37 +0100
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2016-01-12 14:52:37 +0100
commite8bbb3ec7ef07b73e98fc535d7bd04a67c385c79 (patch)
treea00071b2ff8d05312a7d0e474fa160d2f7d5894c /applause.lua
parent6bc561126d8c847fdd2d69f57d7f4c85b3bb08a9 (diff)
downloadapplause2-e8bbb3ec7ef07b73e98fc535d7bd04a67c385c79.tar.gz
fixed memory leaking in Stream:play() due to garbage collector disabling
Diffstat (limited to 'applause.lua')
-rw-r--r--applause.lua21
1 files changed, 11 insertions, 10 deletions
diff --git a/applause.lua b/applause.lua
index 94fd998..163d9e9 100644
--- a/applause.lua
+++ b/applause.lua
@@ -401,16 +401,16 @@ function Stream:play()
jit.on(true, true)
jit.on(tick, true)
- -- Perform garbage collection cycle and turn it off
- -- temporarily. This improves the realtime properties
- -- of the sample generation loop below.
- -- FIXME: Since stopping the garbage collector here
- -- (in the Lua/C code this did not happen!?), memory
- -- consumption increases constantly. Perhaps it is a
- -- good idea to tweak garbage collection during the
- -- generator loop.
+ -- Perform garbage collection cycle and tweak it
+ -- to be more realtime friendly.
+ -- FIXME: Since every stream that does not lag will have
+ -- times when it is idle, it may be clever to stop the
+ -- garbage collector and step it manually whenever
+ -- the Jack sample queue is full. However, how to guarantee
+ -- that we step it fast enough to prevent leaks?
collectgarbage("collect")
- collectgarbage("stop")
+ local old_pause = collectgarbage("setpause", 100)
+ local old_stepmul = collectgarbage("setstepmul", 100)
local state
repeat
@@ -433,7 +433,8 @@ function Stream:play()
end
until state == C.APPLAUSE_AUDIO_INTERRUPTED
- collectgarbage("restart")
+ collectgarbage("setpause", old_pause)
+ collectgarbage("setstepmul", old_stepmul)
if state == C.APPLAUSE_AUDIO_INTERRUPTED then
error("SIGINT received", 2)