Project

General

Profile

Actions

Bug #11334

closed

Arrayの操作でcrubyインタプリタのメモリリークが起きる

Added by metanest (Makoto Kishimoto) over 8 years ago. Updated over 8 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-dev:49166]

Description

きしもとです

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


Related issues 1 (0 open1 closed)

Is duplicate of Ruby master - Bug #11332: Arrayの操作でcrubyインタプリタのメモリリークが起きるClosedActions
Actions #1

Updated by wanabe (_ wanabe) over 8 years ago

  • Is duplicate of Bug #11332: Arrayの操作でcrubyインタプリタのメモリリークが起きる added

Updated by wanabe (_ wanabe) over 8 years ago

  • Status changed from Open to Closed
Actions

Also available in: Atom PDF

Like0
Like0Like0