develooper Front page | perl.perl5.porters | Postings from July 2000

[ID 20000731.009] Does not free memory when deleting hash keys < 1M,!

Thread Next
From:
jbrown
Date:
July 31, 2000 17:22
Subject:
[ID 20000731.009] Does not free memory when deleting hash keys < 1M,!
Message ID:
20000731231558.2409.qmail@dilbert.iz.com
This is a bug report for perl from bextreme@pobox.com,
generated with the help of perlbug 1.28 running under perl v5.6.0.


-----------------------------------------------------------------
[Please enter your report here]

 When deleting entries from a hash, the memory they took is never freed 
(not even on destruction of the hash), unless that entry is huge (like 1M+). 
 Attacted is a script that demonstrates this problem (beware it stores 1000
100k entries, taking 100M when run). 
 When run with 1000 100k entries, it NEVER FREES THE MEMORY, even on hash 
destruction, until the script ends. When run with 100 1M entries, it visibly frees memory. (just change count and size to change memory consumption)

My method of viewing memory size is with
 ps -axv  

As I am sure you can guess, this is a MAJOR problem. I have situations where I
load 200+ entries into a hash, and delete them when I am done, and it never gets
freed. Any help at all would be appreciated.

--- Duplication script. --

#!/usr/bin/perl

$| = 1;
my %hash;
my $count = 1000;
my $size = 102400;
for my $i ( 1 .. $count ) {
  $hash{$i} = 'A' x $size;
}
print "$count x $size bytes allocated in hash.\n";
for my $i ( 1 .. $count ) {
  delete $hash{$i};
  print ".";
  select(undef,undef,undef,0.1);
}
print "\nDestroying hash.";
%hash = ();
print "\n";
sleep 15;


[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=core
    severity=high
---
Site configuration information for perl v5.6.0:

Configured by root at Thu Apr 27 15:49:46 PDT 2000.

Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration:
  Platform:
    osname=linux, osvers=2.2.14, archname=i386-linux
    uname='linux zap 2.2.14 #20 fri feb 25 19:44:02 pst 2000 i686 unknown '
    config_args='-de -Dprefix=/usr -Darchname=i386-linux -Dprivlib=/usr/lib/perl5 -Darchlib=/usr/lib/perl5/i386-linux -Dsitelib=/usr/lib/perl5/site_perl -Dsitearch=/usr/lib/perl5/site_perl/i386-linux'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=undef d_sfio=undef uselargefiles=define 
    use64bitint=undef use64bitall=undef uselongdouble=undef usesocks=undef
  Compiler:
    cc='cc', optimize='-O2', gccversion=egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
    cppflags='-fno-strict-aliasing -I/usr/local/include'
    ccflags ='-fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
    stdchar='char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -lndbm -lgdbm -ldb -ldl -lm -lc -lposix -lcrypt
    libc=/lib/libc-2.1.2.so, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:
    

---
@INC for perl v5.6.0:
    /usr/lib/perl5/i386-linux
    /usr/lib/perl5
    /usr/lib/perl5/site_perl/i386-linux
    /usr/lib/perl5/site_perl
    /usr/lib/perl5/site_perl
    .

---
Environment for perl v5.6.0:
    HOME=/home/jbrown
    LANG (unset)
    LANGUAGE (unset)
    LC_ALL=POSIX
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/openwin/bin:/usr/games:/usr/oracle/8.1.6r2/bin:/var/qmail/bin:.
    PERL_BADLANG (unset)
    SHELL=/bin/bash


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About