Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Unity-Technologies/bdwgc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Echterhoff <jonas@unity3d.com>2020-05-18 13:09:45 +0300
committerJonas Echterhoff <jonas@unity3d.com>2020-05-18 13:09:45 +0300
commit7027029e20978c23787d5801d9098016e51133c3 (patch)
tree824229b56dcc0cd04d7ce9649626dc6e31d04975
parent35a51fcbf1e64457e46f9655cec7ccc586a13135 (diff)
Add GC_trigger_collection API
-rw-r--r--alloc.c11
-rw-r--r--include/gc.h1
2 files changed, 12 insertions, 0 deletions
diff --git a/alloc.c b/alloc.c
index 095e53b4..af51ffcd 100644
--- a/alloc.c
+++ b/alloc.c
@@ -366,6 +366,12 @@ 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_trigger_collection = FALSE;
+
+GC_API void GC_trigger_collection()
+{
+ GC_should_trigger_collection = TRUE;
+}
/* Have we allocated enough to amortize a collection? */
GC_INNER GC_bool GC_should_collect(void)
@@ -376,6 +382,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_trigger_collection)
+ {
+ GC_should_trigger_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 13c7c2a9..615e4961 100644
--- a/include/gc.h
+++ b/include/gc.h
@@ -2034,6 +2034,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_trigger_collection (void);
/* APIs for getting access to raw GC heap */
/* These are NOT thread safe, so should be called with GC lock held */