Logic Programming

Volume 2401 of the series Lecture Notes in Computer Science pp 194-208


Copying Garbage Collection for the WAM: To Mark or Not to Mark?

  • Bart DemoenAffiliated withDept. of Computer Science
  • , Phuong-Lan NguyenAffiliated withInstitut de Mathématiques Appliquées, UCO
  • , Ruben VandeginsteAffiliated withDept. of Computer Science

* Final gross prices may vary according to local VAT.

Get Access


Garbage collection by copying is becoming more and more popular for Prolog. Copying requires a marking phase in order to be safe: safeness means that the to-space is guaranteed not to overflow. However, some systems use a copying garbage collector without marking prior to copying, and instead postpone the copying of potentially unsafe cells. Such systems only collect small portions of the heap and it is not clear whether postponing works while collecting the whole heap. Moreover, it is shown here that postponing does not solve the problem in a fundamental way. Since marking takes time, it is worth studying the tradeoffs involved. These observations have prompted the experimentation with a series of garbage collectors based on copying without marking and without postponing. In particular, variants were implemented that are named dangerous, optimistic and cautious copying which exhibit various degrees of unsafeness. Versions of each have been implemented based on recursive copying as in most implementations of copy_term/2 and on the Cheney algorithm. Performance on benchmarks suggests that large performance gains can be obtained by skipping the marking phase, that dangerous copying is still relatively safe but can be costly, and that the additional effort of cautious copying over optimistic copying is not worth it. The optimistic collectors based on recursive copying perform best and slightly better than the ones based on Cheney. Cache performance measurements back up the benchmark results.