Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: open, file handles and memory

by mwp (Hermit)
on Jan 13, 2001 at 17:42 UTC ( [id://51594]=note: print w/replies, xml ) Need Help??


in reply to open, file handles and memory

As far as I know, that really depends on the operating system and how it handles open file handles. However, most of the time it will buffer the file--read in one line at a time. I wouldn't worry about it.

Just don't do something like this:

open(FILE, "somefile") or die $!; my @log = <FILE>; # read entire file into RAM close(FILE); foreach my $line (@log) { # do stuff to $line }
That will definitely clutter up your machine's memory!

On the other hand, if you have a gigabyte of RAM and you WANT to load the entire file instead of using slow disk accesses, knock yourself out. =)

Replies are listed 'Best First'.
Re: Re: open, file handles and memory
by Viking (Beadle) on Jan 13, 2001 at 17:58 UTC
    That's what I want to avoid, speed isn't an issue (well within reason), having my server grind to a halt because of it running out of memory would be!! :)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (2)
As of 2024-04-26 00:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found