Beast [B], on Thursday, July 14, 2005 at 18:23 (+0700) typed the
following:

B> Is it possible to limit memory used by perl? I don't want perl program
B> to eat all memory causing OS to freeze.

I think, one way how to limit memory usage by perl is measure its
memory, you didn't write you OS, so here are some:

for win:
    use Win32;
    ...
    my $osname = Win32::GetOSName();
    if ($osname eq 'WinXP/.Net' or $osname eq 'Win2003') {
       print "memory usage: $1 RAM." if `tasklist /FO list /v /FI "PID eq $$"` 
=~ /Mem\s+Usage:\s+(.+)/;
    } else {
       print "memory usage: $1 RAM." if `tlist $$` =~ 
/WorkingSetSize:\s+(\d+\s+\w+)/;
    }

for *nix:
    http://www.perlmonks.org/index.pl?node_id=336856
    or something like that :)

I had similar problems (too big data structure for speed...),
so I limit hash keys to certain value...

-- 

How do you protect mail on web? I use http://www.2pu.net

[>:^[-B  Girlfriend's mad at me.]



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to