Thanks, I think you hit the nub of my confusion here. Since mysub is a sub and I am calling it, when it returns I thought everything it created itself (like I assume a large bitmap of the graph in an array for instance) got released? I guess thats dependent on everything inside that sub being lexical. But if chart::clicker complies with use strict, surely it would not compile if it contained non lexical variables (unless there is a no strict in chart clicker somewhere but I can't find it if there is).
So I added use strict to the test script and realised I didn't define $x and $y inside the sub as lexical, fixed that and rerun the test and got the same result (out of mem).
I don't want to copy each array if possible as theres a lot of data to be copied (actually now I realise copying won't really help). I can see that there is a different way to code this by not originally using a large multidimensional hash to sort my data in the first place, but using hashes makes the coding much easier (at least with my present mindset - maybe if I had originally thought of the problem differently it would be fine) - but, surely it should be possible to use hashes in this way?
Re letting the dataset fall out of scope, is there a way of doing this without copying the array each iteration? I don't need the array once the sub has finished with it. I tried undefing after the call to mysub (in the original code each array ref passed into mysub was a different array hash element IE @{$hash{x}{y{z}}) so I used
$mysub(\@{$hash{x}{y{z}});
undef @{$hash{x}{y{z}};
but that didn't seem to work but maybe my method was incorrect.
I guess memory leak questions are common but are there any obvious things I am doing wrong here? Is this a leak in the chart module resulting in simply not being able to use it so many times in the same execution?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.