add ruby_gc_malloc_trim.patch
rvm install 2.7.6 -C --with-jemalloc --patch ruby_gc_malloc_trim.patch
This commit is contained in:
parent
78f1100319
commit
224705bae7
|
@ -0,0 +1,33 @@
|
|||
diff --git a/configure.ac b/configure.ac
|
||||
index d251da9915..5e2a67db1b 100644
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -1825,6 +1825,7 @@ AC_CHECK_FUNCS(lstat)
|
||||
AC_CHECK_FUNCS(lutimes)
|
||||
AC_CHECK_FUNCS(malloc_usable_size)
|
||||
AC_CHECK_FUNCS(malloc_size)
|
||||
+AC_CHECK_FUNCS(malloc_trim)
|
||||
AC_CHECK_FUNCS(mblen)
|
||||
AC_CHECK_FUNCS(memalign)
|
||||
AC_CHECK_FUNCS(memset_s)
|
||||
diff --git a/gc.c b/gc.c
|
||||
index 1331ef21dc..12caa162e7 100644
|
||||
--- a/gc.c
|
||||
+++ b/gc.c
|
||||
@@ -6660,7 +6660,15 @@ gc_start(rb_objspace_t *objspace, int reason)
|
||||
|
||||
gc_prof_timer_start(objspace);
|
||||
{
|
||||
- gc_marks(objspace, do_full_mark);
|
||||
+ gc_marks(objspace, do_full_mark);
|
||||
+#ifdef HAVE_MALLOC_TRIM
|
||||
+ /* [Experimental] Explicitly free all eligible pages to the kernel. See:
|
||||
+ *
|
||||
+ * - https://www.joyfulbikeshedding.com/blog/2019-03-14-what-causes-ruby-memory-bloat.html
|
||||
+ * - https://bugs.ruby-lang.org/issues/15667
|
||||
+ */
|
||||
+ if (do_full_mark) malloc_trim(0);
|
||||
+#endif
|
||||
}
|
||||
gc_prof_timer_stop(objspace);
|
||||
|
Loading…
Reference in New Issue