We don't bite newbies here... much | |
PerlMonks |
Re: Hard to Debug windows memory errorby jandrew (Chaplain) |
on Mar 05, 2016 at 20:06 UTC ( [id://1156896]=note: print w/replies, xml ) | Need Help?? |
Status Update 3: In a potentially unrelated issue, while working on the code base that originally prompted the question I ran into another garbage collection issue on a different windows machine. I'm still in the process of getting the test suit to fully pass after the fix but I thought it useful to post what I found since it is relevant to at least one thread in this overall node. For those in the know it turns out that perl does two-stage garbage collection and for objects that have circular references (which mine do in spades) the object destruction is deferred to the exit phase not just when the variable where the object is stored goes out of scope. There is a warning about this in perldoc for perl 5.8 but the perldocs for 5.22 Destruction are silent on this issue luckily my google foo was strong when I found this. Additionally, The very underrated but handy Perl Cookbook has a specific recipe (13.13) to fix this as well! I have included two sets of example code that represent information gleaned from both sources. The first download is an object module that is self referential but still cleans up as soon as it goes out of scope (Ring.pm) and the second is a script which uses the module for demonstration and then shows some de-referencing magic for simple recursively referenced objects. I have chosen to use the Cookbook style solution in my case. Ring.pm
Recursive_Object_Test.pl
Update: removed link to the pirated copy of the Perl Cookbook with apologies
In Section
Seekers of Perl Wisdom
|
|