All Manuals > LispWorks User Guide and Reference Manual > 49 The SYSTEM Package




Mobile GC only: Sweeps objects for the Mobile GC.




mobile-gc-sweep-objects function &key permanent permanent-weak permanent-non-pointer permanent-new long-lived static large gen-0 gen-1 gen-2



A function or fbound symbol that takes one argument.

permanent, permanent-weak, permanent-non-pointer, permanent-new, long-lived, static, large, gen-0, gen-1, gen-2



The function mobile-gc-sweep-objects sweeps objects in the manner that sweep-all-objects and sweep-gen-num-objects do, but gives you a better control over which objects are swept. It is therefore most efficient for sweeping certain subsets of the objects.

function is called with each object that matches the criteria specified by non-nil values of the keyword arguments.

Permanent objects are objects that the GC does not scan or free, which include objects that were alive when the image was delivered and objects that were alive when make-current-allocation-permanent was called. Large objects that were made permanent by make-object-permanent or make-permanent-simple-vector are also permanent, but in mobile-gc-sweep-objects sweeping them is controlled by large.

permanent defaults to nil. It controls whether sweeping includes permanent objects that contain pointers, and is also the default value for permanent-weak, permanent-non-pointer and permanent-new. permanent-weak controls sweeping of permanent weak objects. permanent-non-pointer control sweeping of permanent objects that do not contain pointers. permanent-new controls sweeping of objects that were made permanent by a call to make-current-allocation-permanent.

long-lived defaults to nil, and is used as the default value for gen-2, gen-1, large and static. gen-0 defaults to nil. Therefore, if long-lived is non-nil and no other keyword arguments are supplied, then all non permanent objects are swept except those in generation 0.

gen-2, gen-1, gen-0, large and static control the sweeping of ordinary objects in generation 2, generation 1, generation 0, large objects and static objects respectively.


With the default values of the keywords, mobile-gc-sweep-objects does nothing.

mobile-gc-sweep-objects is useful for sweeping specific objects, for example all static objects. For this case, it is much more efficient than using sweep-all-objects and checking each object using staticp.

mobile-gc-sweep-objects is thread-safe but not atomic with respect to allocation or GC, so gets confused if a GC occurs while it is sweeping segments that are affected by the GC or there is allocation in any of these segments. It is therefore rarely useful to sweep generation 0, and sweeping generation 1 is probably not useful either.

See also

Mobile GC technical details

LispWorks User Guide and Reference Manual - 20 Sep 2017