Just a stab in the dark but why not fork a child to do you loop? After you are down with the loop the child ends and should not the memory be reclaimed?
------ The Price of Freedom is Eternal Vigilance
Comment on Re: Re: Re: MemLeak in Perl from C Calls
Good point ...
BUT only for this cooked down example. We actually need to get data from
that perl call back into the main program. That is database access via DBI, reading
(and parsing ;-) of text-files, evaluating perl code that gets some configuration etc....