summaryrefslogtreecommitdiff
path: root/gc.c
diff options
context:
space:
mode:
authorPeter Zhu <peter@peterzhu.ca>2023-02-01 09:08:57 -0500
committerPeter Zhu <peter@peterzhu.ca>2023-02-01 13:23:55 -0500
commitc6f84e918943a0bf8db6fee556fc53180d257510 (patch)
treed227af24619080a2700aaa869cd5334d3dce4650 /gc.c
parent375f527ded72cd20374144dd605e0177945b9fae (diff)
[Bug #19398] Memory leak in WeakMap
There's a memory leak in ObjectSpace::WeakMap due to not freeing the `struct weakmap`. It can be seen in the following script: ``` 100.times do 10000.times do ObjectSpace::WeakMap.new end # Output the Resident Set Size (memory usage, in KB) of the current Ruby process puts `ps -o rss= -p #{$$}` end ```
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/7223
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/gc.c b/gc.c
index 269d46daef..3baed251f4 100644
--- a/gc.c
+++ b/gc.c
@@ -12870,6 +12870,7 @@ wmap_free(void *ptr)
st_foreach(w->obj2wmap, wmap_free_map, 0);
st_free_table(w->obj2wmap);
st_free_table(w->wmap2obj);
+ xfree(w);
}
static int