Project

General

Profile

Bug #8095

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

Added by tmm1 (Aman Gupta) about 5 years ago. Updated about 5 years ago.

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

Description

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

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

diff --git a/gc.c b/gc.c
index bd95073..4103af6 100644
--- a/gc.c
+++ b/gc.c
@@ -1973,8 +1973,9 @@ before_gc_sweep(rb_objspace_t *objspace)
objspace->heap.do_heap_free = (size_t)((heaps_used * HEAP_OBJ_LIMIT) * 0.65);
objspace->heap.free_min = (size_t)((heaps_used * HEAP_OBJ_LIMIT) * 0.2);
if (objspace->heap.free_min < initial_free_min) {

  • objspace->heap.do_heap_free = heaps_used * HEAP_OBJ_LIMIT; objspace->heap.free_min = initial_free_min;
  • if (objspace->heap.do_heap_free < initial_free_min)
  • objspace->heap.do_heap_free = initial_free_min; } objspace->heap.sweep_slots = heaps; objspace->heap.free_num = 0;

Related issues

Related to Backport200 - Backport #8145: Backport r39810Closed2013-03-22

Associated revisions

Revision 03c7f0ca
Added by nari about 5 years ago

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

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

Revision 39810
Added by nari about 5 years ago

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

Revision 39810
Added by nari about 5 years ago

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

Revision 39810
Added by nari about 5 years ago

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

Revision 39810
Added by nari about 5 years ago

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

Revision 39810
Added by nari about 5 years ago

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

Revision 8e4d69ad
Added by nagachika (Tomoyuki Chikanaga) about 5 years ago

merge revision(s) 39810: [Backport #8145]

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

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

History

#1 Updated by authorNari (Narihiro Nakamura) about 5 years 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 RUBY_FREE_MIN. patched by tmm1(Aman Gupta). [Bug #8095]

Also available in: Atom PDF