[ruby-core:66677] [ruby-trunk - Bug #10537] Repeated creation and garbage collection of WeakRef instances against a single object leaks memory

From: alex@...
Date: 2014-12-04 08:21:17 UTC
List: ruby-core #66677
Issue #10537 has been updated by Alex Boyd.


I'm no longer able to reproduce the issue on trunk, so this looks fine. I tested both patches and Eric's does indeed run faster and with less memory, with 7.3 MB and

~~~
real	0m5.028s
user	0m5.001s
sys 	0m0.024s
~~~

as opposed to ~20 MB and

~~~
real	0m18.736s
user	0m18.687s
sys 	0m0.041s
~~~

but both appear to work equally well other than that.

----------------------------------------
Bug #10537: Repeated creation and garbage collection of WeakRef instances against a single object leaks memory
https://bugs.ruby-lang.org/issues/10537#change-50282

* Author: Alex Boyd
* Status: Open
* Priority: Normal
* Assignee: 
* Category: lib
* Target version: 
* ruby -v: ruby 2.2.0dev (2014-11-24 trunk 48552) [x86_64-darwin14]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
~~~ruby
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.



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

In This Thread

Prev Next