[ruby-dev:49170] [Ruby trunk - Bug #11334] [Closed] Arrayの操作でcrubyインタプリタのメモリリークが起きる

From: s.wanabe@...
Date: 2015-07-04 14:54:49 UTC
List: ruby-dev #49170
Issue #11334 has been updated by _ wanabe.

Status changed from Open to Closed

----------------------------------------
Bug #11334: Arrayの操作でcrubyインタプリタのメモリリークが起きる
https://bugs.ruby-lang.org/issues/11334#change-53281

* Author: Makoto Kishimoto
* Status: Closed
* Priority: Normal
* Assignee: 
* ruby -v: 
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
 きしもとです
 
 Array の sort! と、pop または shift の操作を組み合わせると、わずか
 ですが ruby インタプリタのメモリリークを引き起こすようです。多数回
 繰返すと、どんどん大きくなります。
 
 以下のサンプルを手元の環境(FreeBSD/amd64のruby 2.1.6、ruby 2.2.2、
 trunk (r51120) )で試すと、どれもインタプリタのプロセスのメモリ
 サイズが大きくなっていきます(最後はメモリを確保できなくなって
 落ちる)。
 # ObjectSpace.memsize_of_all で調べるとオブジェクトは増えたり
 # 大きくなったりはしていません。
 
 # -*- mode:ruby ; coding:utf-8 -*-
 
 def sample rg
 	arr = []
 	sz = 5 + rg.rand(5)
 	i = 0
 	while i < sz do
 		arr[i] = rg.rand
 		i += 1
 	end
 	until arr.empty? do
 		arr.sort!
 
 		arr.pop
 		#arr.shift
 	end
 end
 
 randgen = Random.new 12345
 count = 0
 while true do
 	sample randgen
 	if (count += 1) > 1000000 then
 		count = 0
 		p "GC"
 		GC.start
 	end
 end



-- 
https://bugs.ruby-lang.org/

In This Thread

Prev Next