Help - Search - Member List - Calendar
Full Version: Limit memory used by perl
WorkTheWeb Forums > Webmaster Resources > Perl Beginner Help
Support our Sponsors!
Beast
Hi all,


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


--

--beast

Ing. Branislav Gerzo
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 $$"` =~ /Mems+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.]

Beast
Brent Clark wrote:
QUOTE
Beast wrote:

Hi all,


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



Hi

Maybe you should relook / think yout app and see where you can make it
more effienct


Yes maybe :-p
I have prototype that should parse big log files (680MB) converted into
nice GUI apps. It's not nice if the machine totaly freeze during testing.
(linux 512MB/2GB swap).

--

--beast

Brent Clark
Beast wrote:
QUOTE
Hi all,


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



Hi

Maybe you should relook / think yout app and see where you can make it
more effienct

Kind Regards
Brent Clark

P.s. How much memory is the machine using?

Robin
On Thursday 14 July 2005 23:23, Beast wrote:
QUOTE
Is it possible to limit memory used by perl? I don't want perl program
to eat all memory causing OS to freeze.
If you're on a UNIX or Linux, look into 'ulimit'. It allows you to set per

account (and maybe per-process, I haven't really gotten into it) limits
on things like memory and CPU.

--
Robin <[Email Removed]> JabberID: <[Email Removed]>

Hostes alienigeni me abduxerunt. Qui annus est?

PGP Key 0xA99CEB6D = 5957 6D23 8B16 EFAB FEF8 7175 14D3 6485 A99C EB6D


PHP Help | Linux Help | Web Hosting | Reseller Hosting | SSL Hosting
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2006 Invision Power Services, Inc.