Re: Analize Java source file with perl?



Jenda Krynicky wrote:
From: "Dr.Ruud" <rvtol+news@xxxxxxxxxxxx>
Ovid schreef:

my $text = do { local $/; <$fh> };
There is a problem with this idiom: it uses about twice the memory of
this variant:

my $text ; { local $/ ; $text = <$fh> }

So if your files can be big (related to the amount of memory
available), use the latter.

How do you know? it doesn't seem to be the case. I tried to load a
2MB file both ways and the memory consumption seemed to be the same
(plus or minus a few KB).

I tried then to load a 72MB file and the memory consuption was
77,532KB with the do{} and 77,452KB without. Not sure why the
difference, but it's definitely not twice more.

Unless of course I overlooked something.

If you want to use less memory than either:

read $fh, my $text, -s $fh;



John
--
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order. -- Larry Wall
.



Relevant Pages

  • Re: Memory limit reached with Windows Mobile
    ... That would explain the memory problem - you just can't do that. ... You have to load stuff when it's ... All native DLLs get loaded ...
    (microsoft.public.pocketpc.developer)
  • Re: Memory limit reached with Windows Mobile
    ... That would explain the memory problem - you just can't do that. ... Once I reached the 12 Mb limit, I cannot load any DLLs, yet if I ... Actually, simply by loading our 18 Native DLLs, we reduce the Virtual ...
    (microsoft.public.pocketpc.developer)
  • Re: Generating one table with a terabyte of data
    ... Take any simple string matching issues and run them as external C code on the files before loading. ... not match the job but can be adjusted for greater performance by changing memory type or adjusting IO layouts. ... them after a bulk load. ... Another thing is to split the updates across file sets. ...
    (microsoft.public.sqlserver.dts)
  • Re: fps modding
    ... > Yeah the memory usage used to be really high for no reason - but they've ... hl2 without it bothering to log in and such. ... one can't expect new games to load as ... >> rebuild and load a map. ...
    (comp.games.development.programming.misc)
  • Re: major iis5 asp performance problems
    ... takes to load, ... memory and dip into virtual memory, at which point hard-drive thrashes and ... is why the app gets to 50-60MB. ... >>- IIS performace tab settings ...
    (microsoft.public.inetserver.iis)