in reply to Perl releasing memory back to the system
#!/usr/local/bin/perl -w use strict; $|=1; { my $string; for (1 .. 100000) { $string .= ('x' x 1000); } print "press enter to release"; <>; undef $string; # note that memory does not get released # if the variable only goes out of scope. # you *need* to undef it! } print "ok, press enter to exit"; <>;
This takes up roughly a 100 Mb on my machine, and almost all of it gets released after the first enter. (according to top, at least)
perl -V Summary of my perl5 (revision 5 version 8 subversion 6) configuration: Platform: osname=linux, osvers=2.6.8.20050102, archname=i686-linux
uname='linux sepia 2.6.8.20050102 #1 sun jan 2 14:47:32 cet 2005 i +686 gnulinux ' config_args='-DDEBUGGING -DLEAKTEST' hint=previous, useposix=true, d_sigaction=define usethreads=undef use5005threads=undef useithreads=undef usemultipl +icity=undef useperlio=define d_sfio=undef uselargefiles=define usesocks=undef use64bitint=undef use64bitall=undef uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cc', ccflags ='-fno-strict-aliasing -pipe -I/usr/local/include + -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', optimize='-g -DDEBUGGING -DLEAKTEST', cppflags='-fno-strict-aliasing -pipe -I/usr/local/include -fno-str +ict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_O +FFSET_BITS=64 -fno-strict-aliasing -pipe -I/usr/local/include -D_LARG +EFILE_SOURCE -D_FILE_OFFSET_BITS=64' ccversion='', gccversion='3.3.5 (Debian 1:3.3.5-8)', gccosandvers= +'' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=1 +2 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', + lseeksize=8 alignbytes=4, prototype=define Linker and Libraries: ld='cc', ldflags =' -L/usr/local/lib' libpth=/usr/local/lib /lib /usr/lib libs=-lnsl -ldb -ldl -lm -lcrypt -lutil -lc perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc libc=/lib/libc-2.3.2.so, so=so, useshrplib=false, libperl=libperl. +a gnulibc_version='2.3.2' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E' cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib' Characteristics of this binary (from libperl): Compile-time options: DEBUGGING USE_LARGE_FILES Built under linux Compiled at Mar 15 2005 20:40:51 @INC: /usr/local/lib/perl5/5.8.6/i686-linux /usr/local/lib/perl5/5.8.6 /usr/local/lib/perl5/site_perl/5.8.6/i686-linux /usr/local/lib/perl5/site_perl/5.8.6 /usr/local/lib/perl5/site_perl
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perl releasing memory back to the system
by zentara (Cardinal) on Apr 07, 2005 at 20:00 UTC |