in reply to Memory efficient design

Hello harangzsolt33,

from the little I know it is very rare that memory is actually released to the OS. I think that some memory can be reused by your perl program but I suspect it will not be released (maybe this depends on the OS?).

Waiting for other more expert answers you can consider to use a memory profiling program to test out your assumption: Devel::SizeMe and Devel::Size seems to be appriopriate choices.

You can also consider to not load at all the file in memory: File::Map does exactly this. See memory-map-files-instead-of-slurping-them.

L*

PS please add some <code> tags around your code

PPS see also Mini-Tutorial: Perl's Memory Management which suprised me with the sentence: You are more likely to see memory being released to the OS on Windows

PPPS Perl and Garbage Collection linking to Do subroutine variables get destroyed?

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.