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

Re: Reducing memory usage while matching log entries

by Fletch (Bishop)
on Feb 01, 2006 at 14:54 UTC ( [id://527067]=note: print w/replies, xml ) Need Help??


in reply to Reducing memory usage while matching log entries

Yeah, without sample data it's hard to give advice. But the correct way to remove an element from a hash is with delete, not by assigning an empty string. And you're doing something really weird with @lines; if you get to line 100,000 it's going to allocate a 100,000 element array. Considering it's probably sparse you should use a hash for that as well.

If you're still running into memory issues you might look at using a tied hash (DB_File or BerkeleyDB) or even DBD::SQLite to store stuff you've seen somewhere easily retrieved. Those wouldn't keep much of anything in memory but fetching to see the state of a given address should still be pretty quick.

Replies are listed 'Best First'.
Re^2: Reducing memory usage while matching log entries
by matt.tovey (Beadle) on Feb 01, 2006 at 15:49 UTC
    And you're doing something really weird with @lines; if you get to line 100,000 it's going to allocate a 100,000 element array. Considering it's probably sparse you should use a hash for that as well.

    Yes, that's the file being held in memory. :(

    I just tried putting that into a hash (also using 'delete' now - thanks!). It runs only slightly slower, and consumes quite a bit less memory, so success there!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://527067]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2024-03-28 14:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found