Created
February 9, 2013 12:44
-
-
Save mrkn/4745167 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/gc.c b/gc.c | |
index f307ecb..084b611 100644 | |
--- a/gc.c | |
+++ b/gc.c | |
@@ -393,6 +393,7 @@ typedef struct rb_objspace { | |
struct gc_list *global_list; | |
size_t count; | |
int gc_stress; | |
+ int gc_disable_lazy_sweep; | |
} rb_objspace_t; | |
#if defined(ENABLE_VM_OBJSPACE) && ENABLE_VM_OBJSPACE | |
@@ -419,6 +420,7 @@ int *ruby_initial_gc_stress_ptr = &rb_objspace.gc_stress; | |
#define deferred_final_list objspace->final.deferred | |
#define global_List objspace->global_list | |
#define ruby_gc_stress objspace->gc_stress | |
+#define ruby_gc_disable_lazy_sweep objspace->gc_disable_lazy_sweep | |
#define initial_malloc_limit initial_params.initial_malloc_limit | |
#define initial_heap_min_slots initial_params.initial_heap_min_slots | |
#define initial_free_min initial_params.initial_free_min | |
@@ -445,6 +447,7 @@ void | |
rb_gc_set_params(void) | |
{ | |
char *malloc_limit_ptr, *heap_min_slots_ptr, *free_min_ptr; | |
+ char *disable_lazy_sweep_ptr; | |
if (rb_safe_level() > 0) return; | |
@@ -480,6 +483,15 @@ rb_gc_set_params(void) | |
initial_free_min = free_min_i; | |
} | |
} | |
+ | |
+ disable_lazy_sweep_ptr = getenv("RUBY_GC_DISABLE_LAZY_SWEEP"); | |
+ if (disable_lazy_sweep_ptr != NULL) { | |
+ int disable_lazy_sweep_i = atoi(disable_lazy_sweep_ptr); | |
+ if (RTEST(ruby_verbose)) | |
+ fprintf(stderr, "disable_lazy_sweep=%d (%d)\n", | |
+ disable_lazy_sweep_i, rb_objspace.gc_disable_lazy_sweep); | |
+ rb_objspace.gc_disable_lazy_sweep = disable_lazy_sweep_i; | |
+ } | |
} | |
#if defined(ENABLE_VM_OBJSPACE) && ENABLE_VM_OBJSPACE | |
@@ -2273,7 +2285,7 @@ gc_lazy_sweep(rb_objspace_t *objspace) | |
int res; | |
INIT_GC_PROF_PARAMS; | |
- if (objspace->flags.dont_lazy_sweep) | |
+ if (ruby_gc_disable_lazy_sweep || objspace->flags.dont_lazy_sweep) | |
return garbage_collect(objspace); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/gc.c b/gc.c | |
index 341863d..b6fbbee 100644 | |
--- a/gc.c | |
+++ b/gc.c | |
@@ -253,6 +253,7 @@ typedef struct rb_objspace { | |
size_t total_allocated_object_num; | |
size_t total_freed_object_num; | |
int gc_stress; | |
+ int gc_disable_lazy_sweep; | |
struct mark_func_data_struct { | |
void *data; | |
@@ -284,6 +285,7 @@ int *ruby_initial_gc_stress_ptr = &rb_objspace.gc_stress; | |
#define deferred_final_list objspace->final.deferred | |
#define global_List objspace->global_list | |
#define ruby_gc_stress objspace->gc_stress | |
+#define ruby_gc_disable_lazy_sweep objspace->gc_disable_lazy_sweep | |
#define initial_malloc_limit initial_params.initial_malloc_limit | |
#define initial_heap_min_slots initial_params.initial_heap_min_slots | |
#define initial_free_min initial_params.initial_free_min | |
@@ -2039,7 +2041,7 @@ gc_prepare_free_objects(rb_objspace_t *objspace) | |
{ | |
int res; | |
- if (objspace->flags.dont_lazy_sweep) | |
+ if (ruby_gc_disable_lazy_sweep || objspace->flags.dont_lazy_sweep) | |
return garbage_collect(objspace); | |
@@ -3291,6 +3293,7 @@ void | |
rb_gc_set_params(void) | |
{ | |
char *malloc_limit_ptr, *heap_min_slots_ptr, *free_min_ptr; | |
+ char *disable_lazy_sweep_ptr; | |
if (rb_safe_level() > 0) return; | |
@@ -3326,6 +3329,15 @@ rb_gc_set_params(void) | |
initial_free_min = free_min_i; | |
} | |
} | |
+ | |
+ disable_lazy_sweep_ptr = getenv("RUBY_GC_DISABLE_LAZY_SWEEP"); | |
+ if (disable_lazy_sweep_ptr != NULL) { | |
+ int disable_lazy_sweep_i = atoi(disable_lazy_sweep_ptr); | |
+ if (RTEST(ruby_verbose)) | |
+ fprintf(stderr, "disable_lazy_sweep=%d (%d)\n", | |
+ disable_lazy_sweep_i, rb_objspace.gc_disable_lazy_sweep); | |
+ rb_objspace.gc_disable_lazy_sweep = disable_lazy_sweep_i; | |
+ } | |
} | |
void |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment