home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!sun4nl!ltb!wierda
- From: wierda@ltb.ltb.bso.nl (Gerben Wierda)
- Newsgroups: comp.lang.perl
- Subject: memory problem with test program
- Message-ID: <2038@ltb.ltb.bso.nl>
- Date: 28 Aug 92 13:05:41 GMT
- Organization: BSO/LT, Baarn, The Netherlands
- Lines: 101
-
- We have several perl programs that use a reasonable lot of data in (assoc)
- arrays. However, freeing those arrays does not make the memory use smaller. Is
- this perl? BSD?
-
- Here is the program and the typical output. The input file has 10000 lines
- with info:
-
- =======================snip snip===============================
- #! /usr/local/bin/perl
-
- &memory;
-
- open(LIST,"companylist");
- @normal = (<LIST>);
- close(LIST);
- print "Normal array created with ", $#normal+1, " elements\n";
- &memory;
-
- open(LIST,"companylist");
- while (<LIST>) {
- $assoc{$_} = 1;
- }
- close(LIST);
- print "Associative array created with ", $#normal+1, " elements\n";
- &memory;
-
- undef @normal;
- print "Normal array undefined\n";
- &memory;
-
- undef %assoc;
- print "Associative array undefined\n";
- &memory;
-
- reset 'a', 'n';
- print "Arrays 'a' and 'n' reset\n";
- &memory;
-
- open(LIST,"companylist");
- @bormal = (<LIST>);
- close(LIST);
- print "Normal array created with ", $#bormal+1, " elements\n";
- &memory;
-
- open(LIST,"companylist");
- while (<LIST>) {
- $bssoc{$_} = 1;
- }
- close(LIST);
- print "Associative array created with ", $#bormal+1, " elements\n";
- &memory;
-
- undef @bormal;
- print "Normal array undefined\n";
- &memory;
-
- undef %bssoc;
- print "Associative array undefined\n";
- &memory;
-
- reset 'b';
- print "Arrays 'b' reset\n";
- &memory;
-
- sub memory {
- open(PS,"ps -u$$ |") || die "Can't run ps, $!\n";
- while (<PS>) {
- ($user,$pid,$cpu,$mem) = split;
- }
- close(PS);
- print "\tMemory use is $mem%.\n";
- }
- =======================snip snip===============================
- Memory use is 1.6%.
- Normal array created with 10141 elements
- Memory use is 11.5%.
- Associative array created with 10141 elements
- Memory use is 15.2%.
- Normal array undefined
- Memory use is 15.2%.
- Associative array undefined
- Memory use is 15.2%.
- Arrays 'a' and 'n' reset
- Memory use is 15.2%.
- Normal array created with 10141 elements
- Memory use is 15.3%.
- Associative array created with 10141 elements
- Memory use is 15.3%.
- Normal array undefined
- Memory use is 15.3%.
- Associative array undefined
- Memory use is 15.3%.
- Arrays 'b' reset
- Memory use is 15.3%.
-
- =======================snip snip===============================
- --
- wierda@ltb.bso.nl (Gerben Wierda) || I speak for myself and not for my employer.
- (+31) 2154 84415/(+31) 35 833539 || Support the League for Programming Freedom!
- "If you don't know where you are going, any road will take you there."
- (Almost from) Lewis Carroll, "Alice in Wonderland".
-