mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
ruby_gc_set_params: update malloc_limit when env is set
During VM startup, rb_objspace_alloc sets malloc_limit (objspace->malloc_params.limit) before ruby_gc_set_params is called, thus nullifying the effect of RUBY_GC_MALLOC_LIMIT before the initial GC run. The call sequence is as follows: main.c::main() ruby_init ruby_setup Init_BareVM rb_objspace_alloc // malloc_limit = gc_params.malloc_limit_min; ruby_options ruby_process_options process_options ruby_gc_set_params // RUBY_GC_MALLOC_LIMIT => gc_params.malloc_limit_min With ruby_gc_set_params setting malloc_limit, RUBY_GC_MALLOC_LIMIT affects the process sooner. [ruby-core:107170]
This commit is contained in:
parent
4a4485adbd
commit
a19b2d59fc
1 changed files with 4 additions and 2 deletions
6
gc.c
6
gc.c
|
@ -11267,6 +11267,7 @@ gc_set_initial_pages(void)
|
||||||
void
|
void
|
||||||
ruby_gc_set_params(void)
|
ruby_gc_set_params(void)
|
||||||
{
|
{
|
||||||
|
rb_objspace_t *objspace = &rb_objspace;
|
||||||
/* RUBY_GC_HEAP_FREE_SLOTS */
|
/* RUBY_GC_HEAP_FREE_SLOTS */
|
||||||
if (get_envparam_size("RUBY_GC_HEAP_FREE_SLOTS", &gc_params.heap_free_slots, 0)) {
|
if (get_envparam_size("RUBY_GC_HEAP_FREE_SLOTS", &gc_params.heap_free_slots, 0)) {
|
||||||
/* ok */
|
/* ok */
|
||||||
|
@ -11287,7 +11288,9 @@ ruby_gc_set_params(void)
|
||||||
gc_params.heap_free_slots_min_ratio, gc_params.heap_free_slots_max_ratio, TRUE);
|
gc_params.heap_free_slots_min_ratio, gc_params.heap_free_slots_max_ratio, TRUE);
|
||||||
get_envparam_double("RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR", &gc_params.oldobject_limit_factor, 0.0, 0.0, TRUE);
|
get_envparam_double("RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR", &gc_params.oldobject_limit_factor, 0.0, 0.0, TRUE);
|
||||||
|
|
||||||
get_envparam_size ("RUBY_GC_MALLOC_LIMIT", &gc_params.malloc_limit_min, 0);
|
if (get_envparam_size("RUBY_GC_MALLOC_LIMIT", &gc_params.malloc_limit_min, 0)) {
|
||||||
|
malloc_limit = gc_params.malloc_limit_min;
|
||||||
|
}
|
||||||
get_envparam_size ("RUBY_GC_MALLOC_LIMIT_MAX", &gc_params.malloc_limit_max, 0);
|
get_envparam_size ("RUBY_GC_MALLOC_LIMIT_MAX", &gc_params.malloc_limit_max, 0);
|
||||||
if (!gc_params.malloc_limit_max) { /* ignore max-check if 0 */
|
if (!gc_params.malloc_limit_max) { /* ignore max-check if 0 */
|
||||||
gc_params.malloc_limit_max = SIZE_MAX;
|
gc_params.malloc_limit_max = SIZE_MAX;
|
||||||
|
@ -11296,7 +11299,6 @@ ruby_gc_set_params(void)
|
||||||
|
|
||||||
#if RGENGC_ESTIMATE_OLDMALLOC
|
#if RGENGC_ESTIMATE_OLDMALLOC
|
||||||
if (get_envparam_size("RUBY_GC_OLDMALLOC_LIMIT", &gc_params.oldmalloc_limit_min, 0)) {
|
if (get_envparam_size("RUBY_GC_OLDMALLOC_LIMIT", &gc_params.oldmalloc_limit_min, 0)) {
|
||||||
rb_objspace_t *objspace = &rb_objspace;
|
|
||||||
objspace->rgengc.oldmalloc_increase_limit = gc_params.oldmalloc_limit_min;
|
objspace->rgengc.oldmalloc_increase_limit = gc_params.oldmalloc_limit_min;
|
||||||
}
|
}
|
||||||
get_envparam_size ("RUBY_GC_OLDMALLOC_LIMIT_MAX", &gc_params.oldmalloc_limit_max, 0);
|
get_envparam_size ("RUBY_GC_OLDMALLOC_LIMIT_MAX", &gc_params.oldmalloc_limit_max, 0);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue