diff --git a/src/libgap-api.c b/src/libgap-api.c index b78c6d8338..4cd1c0a52f 100644 --- a/src/libgap-api.c +++ b/src/libgap-api.c @@ -67,6 +67,20 @@ void GAP_Initialize(int argc, } +//// +//// Garbage collector interface +//// +void GAP_MarkBag(Obj obj) +{ + MarkBag(obj); +} + +void GAP_CollectBags(BOOL full) +{ + CollectBags(0, full); +} + + //// //// program evaluation and execution //// diff --git a/src/libgap-api.h b/src/libgap-api.h index 5cdea3858f..d2320a34e2 100644 --- a/src/libgap-api.h +++ b/src/libgap-api.h @@ -161,6 +161,26 @@ void GAP_Initialize(int argc, int handleSignals); +//// +//// Garbage collector +//// + +// Manual management of the GAP garbage collector: for cases where you want +// a GAP object to be long-lived beyond the context of the stack frame where +// it was created, it is necessary to call GAP_MarkBag on the object when +// the garbage collector is run by the markBagsCallback function passed to +// GAP_Initialize. +void GAP_MarkBag(Obj obj); + +// Manually run the garbage collector. +// A collection checks all previously allocated objects, including those +// that have survived at least one previous garbage collection. +// A partial collection will attempt to clean up only recently allocated +// objects which have not been garbage-collected yet, and is hence normally +// a faster operation. +void GAP_CollectBags(BOOL full); + + //// //// program evaluation and execution ////