Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Reducing memory usage while matching log entries

by hv (Prior)
on Feb 01, 2006 at 18:28 UTC ( [id://527134]=note: print w/replies, xml ) Need Help??


in reply to Reducing memory usage while matching log entries

I don't understand why you are using the @lines array at all, and without that your memory requirements go way down. The logic would be something like:

  • %locks records currently open locks, with the key being the mutex address and the value being the input file line number where the lock was acquired
  • if a 'locking' line is seen for a locked mutex, report it and overwrite the %locks entry with the newer lock
  • if an 'unlocked' line is seen for a locked mutex, remove the %locks entry
  • if an 'unlocked' line is seen for an unlocked mutex, report it
  • when the input file is exhausted, report all remaining entries in %locks as "never unlocked"

Your existing code is close to that: remove the references to @lines; replace the definition of $count with:

my $count = $.; # input line number
change the action for unlocking to:
delete $locks{$address};
and replace the final foreach (@lines) {print} with:
for (sort keys %locks) { Log 0, "ERROR: address $_ locked at line $locks{$_} but never unlock +ed."; }

Hope this helps,

Hugo

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2024-03-29 05:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found