home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / perl / scripts-convex / profiling / memleaks next >
Encoding:
Internet Message Format  |  1993-07-14  |  1.6 KB

  1. Path: convex!cs.utexas.edu!wupost!uunet!ogicse!ucsd!nic!netlabs!lwall
  2. From: lwall@netlabs.com (Larry Wall)
  3. Newsgroups: comp.lang.perl
  4. Subject: Re: Does Perl have known memory leaks?
  5. Message-ID: <1991Nov6.155147.8938@netlabs.com>
  6. Date: 6 Nov 91 15:51:47 GMT
  7. Article-I.D.: netlabs.1991Nov6.155147.8938
  8. References: <1991Nov5.154907.5189@ms.uky.edu>
  9. Organization: NetLabs, Inc.
  10. Lines: 29
  11.  
  12. In article <1991Nov5.154907.5189@ms.uky.edu> sean@ms.uky.edu (Sean Casey) writes:
  13. : I've been having trouble running some perl scripts on a DOS machine
  14. : (the dos port of perl 4) because it runs out of memory mid-run. Thing
  15. : is, it's just iterating on a very large file. I'm not allocating new
  16. : space or doing anything that would obviously tie up memory. When I
  17. : looked on the Unix box (also perl 4), sure enough, the same script was
  18. : using well over a megabyte of memory.
  19. : Does perl have known memory leaks? Does scanning for patterns perform
  20. : mallocs in perl that aren't ever freed?
  21.  
  22. A couple of small leaks are fixed in 4.018.  One involved foreach loops
  23. with null lists, and the other involved local(*FILEHANDLE).
  24.  
  25. You can test for leaks by compiling with -DLEAKTEST, inserting
  26.  
  27.     warn "New allocations:\n" unless $counter++ % 100;
  28.  
  29. in the middle of your loop, and running your script with -D4096, which
  30. makes the warn command dump out a list of newly allocated memory.  The
  31. numbers reported correspond to arguments to the New() macro or, in the
  32. 700's, the Str_new() macro.
  33.  
  34. If it's not a leak, look in the Space Efficiency section of Chapter 7.
  35.  
  36. It would be fun to write a profiler that added up the amount of memory
  37. allocated for each statement.
  38.  
  39. Larry
  40.