mjd-perl-pm on Mon, 10 Sep 2001 17:29:00 -0400 |
> Btw, anyone know how to order the gc to release memory right away? There is no way. Unless you do some XS thing. > > { > my @array = qw (foo bar); > undef @array; # <-- I want this bugger gone now > } > # is @array's space available now? It isn't available. Perl usually optimizaes for speed rather than for memory use. Here, it figures that if @array became large on the first pass through tht eblock, it will probably be come large on future passes as well. So Perl's doesn't bother to deallocate the array memory, since it guesses it will just have to allocate it next time anyway. I have a partly finished patch here which would allow you to say use less 'memory'; and disable this particular optimization. If you want to have a look at it, dro pme mail. > Well, a slightly more productive question, if you would allow me: > What's an efficient way of tracking down "Out of Memory!" problems? If your Perl supports it, try setting the $^M variable: $^M = 'x' x 102400; Also set $SIG{__DIE__} = sub { # handle out-of memory condition; maybe print a stack trace # or something }; If Perl runs out of memory, it will discard $^M and then call $SIG{__DIE__}. Since you now have 100K of free memory, you can do some last-minute investigation and produce some useful diagnostics while teetering on the brink of the grave. **Majordomo list services provided by PANIX <URL:http://www.panix.com>** **To Unsubscribe, send "unsubscribe phl" to majordomo@lists.pm.org**
|
|