From 13984af8aa468c1fba1702a3efa315691dd27b05 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Tue, 26 Jun 2018 15:56:32 +0200 Subject: [PATCH] awful.spawn.read_lines: Shrink input stream buffer when done (#2289) I do not know how a GDataInputStream / GBufferedInputStream decides about the size of its internal buffer when reading input by line, but in issue #2288, an example where the output of date (about 30 bytes) was read ten times per second caused ten megabytes of memory usage for this internal buffer. Try to save some memory by explicitly shrinking the buffer size when we are done reading from the stream. Reference: https://github.com/awesomeWM/awesome/issues/2288 Signed-off-by: Uli Schlachter --- lib/awful/spawn.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/awful/spawn.lua b/lib/awful/spawn.lua index a51ba36a..5e02793d 100644 --- a/lib/awful/spawn.lua +++ b/lib/awful/spawn.lua @@ -404,6 +404,7 @@ function spawn.read_lines(input_stream, line_callback, done_callback, close) if close then stream:close() end + stream:set_buffer_size(0) if done_callback then protected_call(done_callback) end