Re: Out of memory! When running perl script on windows
- From: "alpha_beta_release" <youknows@xxxxxxxxx>
- Date: 27 Aug 2006 18:50:57 -0700
Hi
i used to do scripting for Bioinformatics and still doing it. Most of
the task is to swallow a huge chunk of text, parse it, then tranfer or
convert into another form (SQL database, other text format etc...). I
had met this kind of problem several times.
Normally what i do is :
1- check for infinite loop, which caused by
+ unchanged variable values (missing $i++ etc.)
+ never fulfilled condition (-1 > 0 etc.)
2- undef not-used variable in the middle of script (sometimes these
variables hold huge data from file, and used only before parsing). So
undef after parsing, and before doing other task, to save memory.
3- optimize (reading file chunk-by-chunk can save memory than slurping
a whole file etc.)
etc.
Peter J. Holzer wrote:
On 2006-08-27 15:30, felad <felad@xxxxxxxxxxx> wrote:
I have found that every single loop the commit memory grow by 6000 K so
I guess this is why the program crash
But I really can't find that cause of it, most of my variable are local
and I can't find any infinite loop
Any ideas ?
First, check that you aren't creating cyclic data structures: The perl
garbage collector cannot free cyclic data structures. If you really need
them, use weak references or destroy them explicitely after you are done
with them.
Second, lexical variables aren't freed immediately after they go out of
scope but only after the function returns. So if you create large
temporary variables, use them inside functions, not in the main program.
Third, modules which may be helpful: Devel::Cycle, Devel::Leak.
Fourth, perl has quite a bit overhead for each object: If you must keep
lots of data in memory, try to keep few large objects instead of many
little ones.
hp
--
_ | Peter J. Holzer | > Wieso sollte man etwas erfinden was nicht
|_|_) | Sysadmin WSR | > ist?
| | | hjp@xxxxxx | Was sonst wäre der Sinn des Erfindens?
__/ | http://www.hjp.at/ | -- P. Einstein u. V. Gringmuth in desd
.
- Follow-Ups:
- Re: Out of memory! When running perl script on windows
- From: Dr.Ruud
- Re: Out of memory! When running perl script on windows
- References:
- Out of memory! When running perl script on windows
- From: felad
- Re: Out of memory! When running perl script on windows
- From: Peter J. Holzer
- Out of memory! When running perl script on windows
- Prev by Date: Re: Splitting a string to access a multilevel hash
- Next by Date: Re: Allowing threading with CGI
- Previous by thread: Re: Out of memory! When running perl script on windows
- Next by thread: Re: Out of memory! When running perl script on windows
- Index(es):
Relevant Pages
|