Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!iuvax!ux1.cso.uiuc.edu!tank!gargoyle!chinet!les From: les@chinet.chi.il.us (Leslie Mikesell) Newsgroups: comp.lang.perl Subject: Re: perl memory usage? Message-ID: <1990Mar22.210715.4191@chinet.chi.il.us> Date: 22 Mar 90 21:07:15 GMT References: <1990Mar19.210743.15896@chinet.chi.il.us> <7480@jpl-devvax.JPL.NASA.GOV> Reply-To: les@chinet.chi.il.us (Leslie Mikesell) Organization: Chinet - Chicago Public Access UNIX Lines: 36 In article <7480@jpl-devvax.JPL.NASA.GOV> lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) writes: >: Does perl release memory previously used by an associative array >: when you do %array = (); ? >You should first of all check with ps to see if the process is actually >growing. If it's not, you're barking up the wrong hash table. Well, it turns out that the arrays and subroutines don't have anything to do with it. Memory is being gobbled by simple scalar assignments out of the pattern match chunks. With patchlevel 14 on AT&T SysvR3.2.1 '386 unix, each pass adds about 7 blocks to the memory size shown by ps. Commenting out the: $show = "$` <-> $'" ; fixes it. Help!!! # test perl memory usage print `ps -fl |grep perl` ; $pre = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' ; $post = 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz' ; for $z (1..50) { print "Pass $z \n"; for $x (1..1000) { $foo{$x} = $pre . $x . $post ; # assoc array } @keylist = sort(keys(%foo)); while ( $keyitem = shift(@keylist)) { if ( $foo{$keyitem} =~ /4/ ) { #### THIS NEXT LINE IS THE PROBLEM ###### $show = "$` <-> $'" ; # print "$show \n" ; } } %foo = (); print `ps -fl |grep perl` ; } #------ Les Mikesell les@chinet.chi.il.us