miniscript icon indicating copy to clipboard operation
miniscript copied to clipboard

C++: change garbage collection to work with orphaned cycles

Open JoeStrout opened this issue 2 years ago • 1 comments

The C++ implementation currently uses reference-counting, which is relatively fast and simple, but can leak circular references.

Switch to another form of garbage collection to fix this problem and bring behavior in line with the C# implementation. Probably either mark-and-sweep, or Cheney's algorithm. The latter sounds like it might perform better, and is simple to implement; see: https://arxiv.org/pdf/1505.00017.pdf

JoeStrout avatar Feb 09 '24 03:02 JoeStrout

Note that strings are probably a special case, because (1) the are used a lot, and (2) they cannot contain any other references.

So it might make sense to continue using reference-counting for them, reducing the amount of work the GC has to do.

JoeStrout avatar Feb 09 '24 12:02 JoeStrout