Skip to content

Commit 61d7a8e

Browse files
authored
in_tail: reduce memory usage slightly (#4881)
**Which issue(s) this PR fixes**: Fixes # **What this PR does / why we need it**: Previous, I changed lifespan of `iobuf` at #4763 to work GC collector well. In addition, it seems that clearing `iobuf` manually when it is no longer needed, it might improve memory efficiency. ![memory_usage](https://github.com/user-attachments/assets/2ed3afeb-edd6-4f9f-ab6f-1bb602390f25) * config ``` <source> @type tail path "#{File.expand_path '~/tmp/access*.log'}" pos_file "#{File.expand_path '~/tmp/fluentd/access.log.pos'}" tag log refresh_interval 5s <parse> @type none </parse> </source> <match **> @type file path "#{File.expand_path '~/tmp/log'}" </match> ``` * script to generate log data ``` require "json" path = File.expand_path("~/tmp/access.log") File.open(path, "w") do |f| loop do log = { time: Time.now, message: "a" * 10_000 }.to_json f.puts log sleep 0.05 end end ``` Related to #4808 **Docs Changes**: **Release Note**: Signed-off-by: Shizuo Fujita <fujita@clear-code.com>
1 parent 5c86e31 commit 61d7a8e

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lib/fluent/plugin/in_tail.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,6 +1238,8 @@ def handle_notify
12381238
end
12391239
rescue EOFError
12401240
@eof = true
1241+
ensure
1242+
iobuf.clear
12411243
end
12421244
end
12431245

0 commit comments

Comments
 (0)