From: "MSP-Greg (Greg L)" Date: 2021-08-28T21:40:00+00:00 Subject: [ruby-core:105081] [Ruby master Bug#18134] Memory leak with master Issue #18134 has been updated by MSP-Greg (Greg L). I'm not that familiar with the best way to measure Ruby memory use. The following code: ```ruby loops = ARGV[0] || 500_000 smem = "smem -c 'pid pss rss uss command'" env = ENV.to_h env_c = nil GC.start; GC.compact system smem 100_000.times { env_c = env.dup } puts '', "Duped hash #{loops} times", '' GC.start; GC.compact system smem ``` Yielded the following. Both Ruby 3.0.2 and master show an increase in memory, but master uses 10 times as much... ``` PID PSS RSS USS 865 20609 22484 20072 Ruby master start 865 120927 122808 120680 " " end 100608 increase 870 20468 22216 19872 Ruby 3.0.2 start 870 30492 32268 29912 " " end 10040 " " increase ``` ---------------------------------------- Bug #18134: Memory leak with master https://bugs.ruby-lang.org/issues/18134#change-93485 * Author: MSP-Greg (Greg L) * Status: Open * Priority: Normal * ruby -v: ruby 3.1.0dev (2021-08-26T10:47:48Z master ef10e8a1eb) [x64-mingw32] * Backport: 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN ---------------------------------------- While working on code to test Puma���s performance, I noticed a memory leak using WSL2 Ubuntu 20.04 and Ruby master. The leak seemed proportional to the number of requests made, and independent of the response size, either headers or body. Locally, I was running up to 2 million requests. The code used @ioquatix���s version of wrk and smem for measuring memory use. I ran GC.start and GC.compact before checking memory. The Puma configuration was using `fork`. I���ve got a lot of Ruby versions on Windows, but haven���t created the same setup for Ubuntu. So, I took the above code and ran it on GitHub Actions Ubuntu 20.04. Ruby 2.5.9, 2.7.4, and 3.0.2 did not have the memory leak, but master had the same leak I saw locally. Puma and one of its dependencies (nio4r) are both extension gems. Has there been an ABI change that might affect the code? I can try to bisect it if that would be helpful. Thanks, Greg -- https://bugs.ruby-lang.org/ Unsubscribe: