Bug #10942
closedSuspected memory leak
Description
There seems to be memory leaking when calling Aws::SQS::Client#receive_message in Ruby 2.2.0 and 2.2.1. I am not very good at memory/object allocation profiling in Ruby, but I know for sure that there must be some issue, because my SQS workers run out of memory every day.
See gist https://gist.github.com/quezacoatl/7657854f371edcb5d8e6 to reproduce. I've added output.txt for my output for different Ruby versions. Ruby 2.1.2 works fine. I'm sorry that I cannot pinpoint the exact issue. Perhaps somebody with better profiling skills can do this?
Files
Updated by eugene (Eugene Pimenov) over 9 years ago
I reduced the test case to
require 'stringio'
require 'securerandom'
loop do
for i in 1..100
StringIO.new << SecureRandom.hex
end
GC.start
end
Can reproduce on trunk.
Updated by normalperson (Eric Wong) over 9 years ago
- File 0001-stringio-avoid-STR_NOFREE-due-to-constant-string.patch 0001-stringio-avoid-STR_NOFREE-due-to-constant-string.patch added
Thanks, I have a fix, but the usage of STR_NOFREE seems dangerous from str_new_static
http://80x24.org/spew/m/b2ff0de539643b27d1bf3e0ebe97bec2d85de2b4.txt
Updated by nobu (Nobuyoshi Nakada) over 9 years ago
- Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN to 2.0.0: DONTNEED, 2.1: DONTNEED, 2.2: REQUIRED
Thank you, it's very helpful.
Updated by nobu (Nobuyoshi Nakada) over 9 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
Applied in changeset r50334.
string.c: clear NOFREE flag at embedding
- string.c (STR_SET_EMBED): clear NOFREE flag at embedding as
embedded strings no longer refer static strings.
[ruby-core:68436] [Bug #10942]
Updated by nagachika (Tomoyuki Chikanaga) over 9 years ago
- Backport changed from 2.0.0: DONTNEED, 2.1: DONTNEED, 2.2: REQUIRED to 2.0.0: DONTNEED, 2.1: DONTNEED, 2.2: DONE
Backported into ruby_2_2
branch at r50550.
I've changed :limit option for assert_no_memory_leak from 1.5 to 2.0. Without the change added test sometimes fails on my environment.