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:

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