Re: Analize Java source file with perl?



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.

Jenda

===== Jenda@xxxxxxxxxxx === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery

.



Relevant Pages

  • Re: managed pool question
    ... You might get out-of-memory errors. ... > and I will load it all at once in loading time. ... > the amount of resources that will be loaded all at once is ...
    (microsoft.public.win32.programmer.directx.graphics)
  • Re: moving data from one place to another in a text file
    ... practical solution - as any solution requiring "memory allocation" canNOT handle ... And, of course, the "read twice method" would be portable to EVERY ANSI/ISO ... >>output the same input file with another name. ...
    (comp.lang.cobol)
  • Re: SLOW typing response time using Mac Office 2008
    ... Anything running on a PPC needs twice the memory of something running on ... Which occupies twice the memory. ... and noticed a marked improvement in the response time, ... But I usually have Safari 3.0.4 running in the background, ...
    (microsoft.public.mac.office.word)
  • Reasons For 64-bit: A Digest
    ... First of all, you are of course, absolutely right about your observation that a 64-bit Pointer is twice the size of a 32-bit pointer. ... I really wish the "64-bit Lobby" had made a digest of our arguments while we were fighting to get a native 64-bit compiler on the Road Map.. ... twice as many registers: double the number of general purpose registers and double the number of XMM registers. ... Expanded address space so instead of being limited to 4 GB of memory you're limited to terabytes of memory. ...
    (borland.public.delphi.non-technical)
  • Re: memory leak in asp 2.0
    ... Almost certainly the problem is in storing large amount of data in session ... I expected that it will get some amount of memory, ... I call each time 'Page unload' when I load new page but never when I close ...
    (microsoft.public.dotnet.framework.aspnet)