| Store | Cart

Re: [perl #125530] Freeing variables referred to by coderefs

From: Zefram <zef...@fysh.org>
Thu, 2 Jul 2015 14:12:40 +0100
Daniel Perrett wrote:
>The attached script contains a variable "$leak". If it has a false value,>an operation is performed in such a way that memory remains constant>(amount varies per system: below 1MB on an Ubuntu perl); with a true>value, it behaves as if there is a memory leak (exceeds 10MB on the>same perl).

Actually both versions leak.  With $leak false it just leaks *less*.
Add system("ps u $$") inside the loop and watch VSZ gradually increasing.

>There are no cyclical references.

There is a cyclical reference: The $pathfinder sub is closed over the
$pathfinder variable which contains a reference to the sub.

-zefram

Recent Messages in this Thread
Daniel Perrett (via RT) Jul 02, 2015 11:08 am
Zefram Jul 02, 2015 01:12 pm
Daniel Perrett Jul 02, 2015 01:45 pm
Ricardo Signes Jul 03, 2015 01:28 am
James E Keenan via RT Jul 02, 2015 11:10 pm
Messages in this thread