diff options
author | Jonas Echterhoff <jonas@unity3d.com> | 2020-05-28 14:02:00 +0300 |
---|---|---|
committer | Jonas Echterhoff <jonas@unity3d.com> | 2020-05-28 14:02:00 +0300 |
commit | fa62401dff24684f8797bc355807e90d78e880af (patch) | |
tree | 4e7dcdaa4bd0029632d418518fb3429133e6d32b | |
parent | 876a56777d9fb8ca559c8889c586cc88eb120d75 (diff) |
Add GC_set_disable_automatic_collection API to disable automatic periodic collectionsdisable-automatic-collection-api
-rw-r--r-- | alloc.c | 8 | ||||
-rw-r--r-- | include/gc.h | 1 |
2 files changed, 9 insertions, 0 deletions
@@ -367,6 +367,12 @@ STATIC void GC_clear_a_few_frames(void) /* limits used by blacklisting. */ STATIC word GC_collect_at_heapsize = (word)(-1); STATIC GC_bool GC_should_start_incremental_collection = FALSE; +STATIC GC_bool GC_disable_automatic_collection = FALSE; + +GC_API void GC_set_disable_automatic_collection(GC_bool disable) +{ + GC_disable_automatic_collection = disable; +} GC_API void GC_start_incremental_collection() { @@ -391,6 +397,8 @@ GC_INNER GC_bool GC_should_collect(void) GC_should_start_incremental_collection = FALSE; return TRUE; } + if (GC_disable_automatic_collection) + return FALSE; return(GC_adj_bytes_allocd() >= last_min_bytes_allocd || GC_heapsize >= GC_collect_at_heapsize); } diff --git a/include/gc.h b/include/gc.h index 3a4501ae..3d10a9a4 100644 --- a/include/gc.h +++ b/include/gc.h @@ -2038,6 +2038,7 @@ GC_API void GC_CALL GC_start_world_external(void); GC_API void GC_CALL GC_disable_incremental(void); GC_API void GC_CALL GC_start_incremental_collection (void); +GC_API void GC_CALL GC_set_disable_automatic_collection(int); /* APIs for getting access to raw GC heap */ /* These are NOT thread safe, so should be called with GC lock held */ |