summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2023-04-25 09:35:16 +0300
committerIvan Maidanski <ivmai@mail.ru>2023-04-25 09:36:04 +0300
commit4bdf9b9c327673b71344a63e368d8b2386bae6af (patch)
tree32451d0a3b368b8c78db67fa34c794ac91bcff04 /include
parent2e5646ba3d954da3f45985630281aadfc686f55b (diff)
downloadbdwgc-4bdf9b9c327673b71344a63e368d8b2386bae6af.tar.gz
Do incremental mark some in GC_collect_a_little even if GC is disabled
Previous behavior was not documented but this API function did nothing in this case. That might cause a deadlock in the client code if the incremental collection was ongoing and the client called GC_collect_a_little() repeatedly (while the result is true). The new behavior, for the cause of disabled garbage collection, is to perform some amount of marking if the incremental collection is ongoing (but not stopping the world and, thus, not causing the memory reclaim to start), returning true if there is something more to mark. * alloc.c (GC_try_to_collect_inner): Change a loop to do-while one. * alloc.c (GC_collect_a_little): Do not check GC_dont_gc (i.e. call GC_collect_a_little_inner() unconditionally); add comment. * include/gc/gc.h (GC_collect_a_little): Update comment (describe the case when GC is disabled). * tests/gctest.c (check_heap_stats): Do not call GC_is_disabled(); add comment.
Diffstat (limited to 'include')
-rw-r--r--include/gc/gc.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/include/gc/gc.h b/include/gc/gc.h
index 3f0d0cc0..06048c6e 100644
--- a/include/gc/gc.h
+++ b/include/gc/gc.h
@@ -957,7 +957,9 @@ GC_API void GC_CALL GC_start_incremental_collection(void);
/* to marking from one page. May do more work if further */
/* progress requires it, e.g. if incremental collection is */
/* disabled. It is reasonable to call this in a wait loop */
-/* until it returns 0. */
+/* until it returns 0. If GC is disabled but the incremental */
+/* collection is already ongoing, then perform marking anyway */
+/* but not stopping the world (and without the reclaim phase). */
GC_API int GC_CALL GC_collect_a_little(void);
/* Allocate an object of size lb bytes. The client guarantees that as */