home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / perl / 8042 < prev    next >
Encoding:
Internet Message Format  |  1993-01-28  |  1.2 KB

  1. Path: sparky!uunet!ferkel.ucsb.edu!taco!rock!concert!uvaarpa!darwin.sura.net!spool.mu.edu!sgiblab!nec-gw!nec-tyo!wnoc-tyo-news!scslwide!wsgw!headgw!cvgw3!tshiono
  2. From: tshiono@cv.sony.co.jp (Toru SHIONO)
  3. Newsgroups: comp.lang.perl
  4. Subject: Out of memory
  5. Message-ID: <TSHIONO.93Jan28205613@cxn21.cv.sony.co.jp>
  6. Date: 28 Jan 93 11:56:13 GMT
  7. Sender: news@cv.sony.co.jp (Usenet News System)
  8. Distribution: comp
  9. Organization: Consumer Video Group, SONY, Osaki New city, Tokyo, JAPAN.
  10. Lines: 34
  11. Nntp-Posting-Host: cxn21
  12.  
  13.  
  14.     I'm trying to process a very huge (1,000,000 lines) file with
  15. a simple Perl script.
  16. The processing is done line by line and it doesn't have to keep
  17. previous lines; so I presume that it will work no matter how the file
  18. may be big.
  19.  
  20. However, Perl complains "Out of memory!"
  21.  
  22. To extract the problem, I tested these scripts:
  23.  
  24.     #!/usr/bin/perl
  25.     foreach (1 .. 1000000) {
  26.         $line = <>;
  27.         print $line;
  28.     }
  29.  
  30. dies shortly, whereas
  31.  
  32.     #!/usr/bin/perl
  33.     for ($i = 0; $i < 1000000; $i++) {
  34.         $line = <>;
  35.         print $line;
  36.     }
  37.  
  38. works fine !
  39.  
  40. What makes the difference ?
  41. I am afraid that the former loop seems to cause memory leak or
  42. something like that.
  43.  
  44. Any suggestions ?
  45. --
  46. Toru Shiono (tshiono@cv.sony.co.jp)     Sony Corporation, JAPAN
  47.