Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Strange memory growth

by tinita (Parson)
on Feb 14, 2018 at 18:42 UTC ( #1209164=note: print w/replies, xml ) Need Help??


in reply to Strange memory growth

Which perl version are you using, which OS?
I don't see a specific problem with the code. It should have a use strict; at the beginning, though.
How long is a typical JSON string?
Can you create a sample input that will show memory increase? For example, instead of reading in the file, just loop over the same line a couple of 1000 times and watch memory consumption.
The problem the others are mentioning doesn't look like a problem to me since $jp falls out of scope after every loop iteration.
Memory stays the same for me if I run this 500,000 times on an example line.

edit: specifically, how many array elements does a typical structure have? my assumption was that you have many lines, but maybe your lines/JSON strings are very big?

Replies are listed 'Best First'.
Re^2: Strange memory growth
by Anonymous Monk on Feb 16, 2018 at 14:50 UTC
    I'm pretty sure that auto-vivification is the root-cause problem here, because a chain of hashrefs was used in a single expression, causing unwanted AV to occur from left to right. And I am also pretty sure that huck had the best answer.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1209164]
help
Chatterbox?
NodeReaper adds to his collection

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (3)
As of 2018-07-19 23:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (421 votes). Check out past polls.

    Notices?