Project

General

Profile

Bug #15422

Re: [ruby-cvs:73514] normal:r66413 (trunk): thread_pthread.c: fix memory leak from fork loop leapfrog (v3)

Added by normalperson (Eric Wong) 2 months ago.

Status:
Open
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:90566]

Description

https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=66413

Finally fixed for GNU/Linux. Not on FreeBSD 11.2,
but it was also present in 2.4.5:

==> fork_leapfrog_freebsd.rb <==
require 'io/wait'
prev = 0
100000.times do
pid = fork
exit!(0) if pid

# show the RSS (FreeBSD 11.x)
n = IO.popen("ps -u #$$", &:readlines)[1].split[5].to_i
if n > prev
puts "#{prev} => #{n}"
prev = n
end

# since Ctrl-C from a terminal can't stop this loop,
# allow the user to just mash the keyboard to stop
break if STDIN.wait(0)
end

Also available in: Atom PDF