diff options
author | jonas echterhoff <jonas@unity3d.com> | 2020-05-26 17:00:06 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-26 17:00:06 +0300 |
commit | 876a56777d9fb8ca559c8889c586cc88eb120d75 (patch) | |
tree | 7f5319d83933aad955721822411eb5eef99e82cd | |
parent | 49e0fa85e4b5ba0bb4b37e14c64e19ca20bd3789 (diff) | |
parent | 0480a661fed6149741aeb318f8aa31a96d9182cb (diff) |
Merge pull request #54 from Unity-Technologies/trigger-gc-api
Add GC_trigger_collection API
-rw-r--r-- | alloc.c | 15 | ||||
-rw-r--r-- | include/gc.h | 1 |
2 files changed, 16 insertions, 0 deletions
@@ -366,6 +366,16 @@ STATIC void GC_clear_a_few_frames(void) /* Heap size at which we need a collection to avoid expanding past */ /* limits used by blacklisting. */ STATIC word GC_collect_at_heapsize = (word)(-1); +STATIC GC_bool GC_should_start_incremental_collection = FALSE; + +GC_API void GC_start_incremental_collection() +{ + if (GC_incremental) + { + GC_should_start_incremental_collection = TRUE; + GC_collect_a_little(); + } +} /* Have we allocated enough to amortize a collection? */ GC_INNER GC_bool GC_should_collect(void) @@ -376,6 +386,11 @@ GC_INNER GC_bool GC_should_collect(void) last_gc_no = GC_gc_no; last_min_bytes_allocd = min_bytes_allocd(); } + if (GC_should_start_incremental_collection) + { + GC_should_start_incremental_collection = FALSE; + return TRUE; + } 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 3540b13f..3a4501ae 100644 --- a/include/gc.h +++ b/include/gc.h @@ -2037,6 +2037,7 @@ GC_API void GC_CALL GC_stop_world_external(void); 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); /* APIs for getting access to raw GC heap */ /* These are NOT thread safe, so should be called with GC lock held */ |