AFAIK, perl 5.8.6 (and probably a couple of earlier versions) can release memory back to the system on Linux.

#!/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

In reply to Re: Perl releasing memory back to the system by Joost
in thread Perl releasing memory back to the system by zentara

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.