Bug #8095

[patch] gc: fix unlimited memory growth with large values of RUBY_FREE_MIN

Added by Aman Gupta about 1 year ago. Updated about 1 year ago.

[ruby-core:53405]
Status:Closed
Priority:Normal
Assignee:Narihiro Nakamura
Category:core
Target version:-
ruby -v:ruby 2.1.0dev (2013-03-14 trunk 39748) [x86_64-darwin12.2.1] Backport:

Description

Normally, doheapfree is set to 65% of total slots available.

But if you specify a very large RUBYFREEMIN, then doheapfree is always set to 100%. This results in a memory leak over time.
Instead of forcing doheapfree = 100%, the following patch sets doheapfree = max( RUBYFREEMIN, 65% )

diff --git a/gc.c b/gc.c
index bd95073..4103af6 100644
--- a/gc.c
+++ b/gc.c
@@ -1973,8 +1973,9 @@ beforegcsweep(rbobjspacet *objspace)
objspace->heap.doheapfree = (sizet)((heapsused * HEAPOBJLIMIT) * 0.65);
objspace->heap.freemin = (sizet)((heapsused * HEAPOBJLIMIT) * 0.2);
if (objspace->heap.free
min < initialfreemin) {
- objspace->heap.doheapfree = heapsused * HEAPOBJLIMIT;
objspace->heap.free
min = initialfreemin;
+ if (objspace->heap.doheapfree < initialfreemin)
+ objspace->heap.doheapfree = initialfreemin;
}
objspace->heap.sweepslots = heaps;
objspace->heap.free
num = 0;


Related issues

Related to Backport200 - Backport #8145: Backport r39810 Closed 03/22/2013

Associated revisions

Revision 39810
Added by nari about 1 year ago

  • gc.c: Fix unlimited memory growth with large values of RUBYFREEMIN. patched by tmm1(Aman Gupta). [Bug #8095]

History

#1 Updated by Narihiro Nakamura about 1 year ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r39810.
Aman, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • gc.c: Fix unlimited memory growth with large values of RUBYFREEMIN. patched by tmm1(Aman Gupta). [Bug #8095]

Also available in: Atom PDF