Forum: Ruby-dev Fiddle::Function#call leaks memory

5cf8f058a4c094bb708174fb43e7a387?d=identicon&s=25 unknown (Guest)
on 2014-05-04 19:34
(Received via mailing list)
Issue #9599 has been updated by Tomoyuki Chikanaga.

Backport changed from 1.9.3: UNKNOWN, 2.0.0: REQUIRED, 2.1: REQUIRED to
1.9.3: UNKNOWN, 2.0.0: REQUIRED, 2.1: DONE

r45291, r45299, r45314 and r45325 were backported into ruby_2_1 at
45820.

----------------------------------------
Bug #9599: Fiddle::Function#call leaks memory
https://bugs.ruby-lang.org/issues/9599#change-46520

* Author: Nobuyoshi Nakada
* Status: Closed
* Priority: Normal
* Assignee: Aaron Patterson
* Category: ext
* Target version: current: 2.2.0
* ruby -v: r45270
* Backport: 1.9.3: UNKNOWN, 2.0.0: REQUIRED, 2.1: DONE
----------------------------------------
`Fiddle::Function#call` seems leaking memory.

With the following code:

```ruby
# fiddle-memleak.rb
require 'fiddle'
n = 10
a = ["a"] * n
f = Fiddle::Function.new(Fiddle.dlopen(nil)["rb_obj_tainted"],
[Fiddle::TYPE_VOIDP]*n, Fiddle::TYPE_VOID)
loop {f.call(*a); GC.start}
```

VSZ and RSS increase continuaslly.

```sh
$ ruby fiddle-memleak.rb & while ps -ovsz=,rss= $!; do sleep 1; done
[1] 93595
 2423344     24
 2461024   8884
 2463072  10420
 2464096  11940
 2465120  13428
 2467168  14948
 2468192  16476
 2469216  17980
 2471264  19432
 2473312  20940
 2474336  22424
 2475360  23936
 2478432  25468
 2481504  26996
 2482528  28468
 2483552  29984
 2485600  31524
 2486624  33056
 2487652  34568
 2488676  36100
 2490724  37628
 2491748  39152
```

RGenGC seems unrelated since the result in 2.0.0 is similar.
This topic is locked and can not be replied to.