Firstly, while a memory leak on the C side is not your problem in this case, you should know that Rakudo installs perl6-valgrind-m , which runs the program under valgrind. I used this several times to figure out segfaults and leaks when writing my library bindings.
To search for objects managed by MoarVM, you can force the VM to dump heap snapshots. They are taken after each start of the GC, and an additional GC start is forced and the final shot taken at the end of the program. To record snapshots, run with --profile=heap . Then the output file can be transferred to moar-ha , which can be installed using zef install App::MoarVM::HeapAnalyzer (it is implemented in Perl 6, which may be useful to know if you want to expand it in some way to help you solve problems).
If you have any idea what kind of objects can leak, then it can be useful to look for objects of this type with the find . There is a path command that shows how this object is kept alive. It may also be useful to look at the number of objects between different heap snapshots to see what is growing in use. Unfortunately, there is no snapshot function yet.
It should be noted that snapshots include everything that runs on a virtual machine. This means that the Perl 6 compiler will be in memory, as well as a bunch of objects for things from embedded languages. (The tool was designed to track managed leaks in the compiler and built-in modules, so this is considered a feature. :-) Some sort of filtering may be possible in the future.)
Finally, you mentioned circular links. This is not a problem in Perl 6, because the GC is done by tracing rather than reference counting.
Jonathan worthington
source share