Project

General

Profile

ActionsLike0

Bug #10537

closed

Repeated creation and garbage collection of WeakRef instances against a single object leaks memory

Added by javawizard (Alex Boyd) over 10 years ago. Updated about 10 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.2.0dev (2014-11-24 trunk 48552) [x86_64-darwin14]
[ruby-core:66428]

Description

require 'weakref'
a = Object.new
1_000_000.times do
  WeakRef.new a
end
GC.start

The above results in Ruby consuming ~150 MB of RAM, all of which can only be freed by dropping a. This should not be the case - an object being weakly referenced should not itself hold a reference to the WeakRef (or any associated data) pointing at it.


Related issues 1 (0 open1 closed)

Related to Ruby - Bug #10618: TestWeakRef#test_repeated_object_leak fails on ARMClosednormalperson (Eric Wong)12/18/2014Actions

Added by Eric Wong over 10 years ago

Revision 85690385

gc.c (define_final0): avoid duplicate blocks

This prevents excessive memory growth when a WeakRef
is repeatedly created

  • gc.c (define_final0): avoid duplicate blocks
    [Bug #10537]
  • test/test_weakref.rb (test_repeated_object_leak): new test

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48820 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

ActionsLike0

Also available in: Atom PDF