Your handling of the perl array looks correct. You create a new AV with a refcount of one. You add a bunch of scalars to the array, each of which is created with a refcount of 1. Crucially, you handle the arrayref correctly, creating a single reference which does not increase the refcount of the AV. This one arrayref ends up on the stack, mortalized via the a call to sv_2mortal from the OUTPUT/RETVAL apparatus. Assuming for the sake of simplicity that we don't copy anything out of @_, when that mortalized ref comes due, your array and all of its members should fall like dominoes.

Thank you. One less place to look at ;)

I think you'll need to look elsewhere. Coincidentally, I'm debugging memory leaks right this moment using valgrind. If you have access to a Linux system, I'd strongly recommend you give it a try.

Unfortunately, I think I will need to do that ;)

Cheers
ambs
--
Alberto Simões - Departamento de Informática - Universidade do Minho
                 Campus de Gualtar - 4710-057 Braga - Portugal

"Beware of bugs in the above code;
 I have only proved it correct, not tried it."
                                   --- Donald Knuth

Reply via email to