in reply to Re: Re: RegEx on 4MB file consumes of 2GB of ram before windows shuts it down.
in thread RegEx on 4MB file consumes of 2GB of ram before windows shuts it down (Memory Leak in 5.8.2)
1) The code does not die. It consumes memory until windows decides not to allow any more. Then I get a windows XP dialog box that says Perl has been naughty an will be closed.
2) Data spans multiple lines, but the priority is just a single 1 byte integer. [\d\D]*? could be replaced with \d*? in this case. However the RegEx was made to be generic, and I just plugged some values into it (some properties contain any character and can span multiple lines).
3) You're right, the two RE's differ, and they're meant to handle the two cases where a priority line does and does not exist. First, this is the data format:
The whitespace may varry.Sound { Name = example; Priority = 99; etc... { (possible sub sections) }etc...
That may make things more clear. In the first RE I can simply replace the number, so I have "$1$pri;". However, in the second, I need to add the a new line, including the correct white space. $1 contains the data up to the point where I want to add the line (that's why I force it to end at the line). $2 contains a carriage return and the leading white space before "Name". So adding it after $1 duplicates the whitespace for my new line. Then I add the new priority line and a carriage return.
It may be true that the whitespace is off (and the backslashes show up in my resulting data). However, that is something that I can easily debug once I start getting output results from the program.
My primary concern is the massive memory consumption, which prevents the program from finishing. It seems as if there is some sort of memory leak where, for example, Perl is creating the $`$&$' variables and then not destroying them for the next itteration.
I could be wrong, and it could be by design, but what I'm hoping for is a way to get perl to do this tasks without using more than 2 gigabytes of ram.
Thanks for the feedback, do you have any idea why this script is using so much memory (and how to avoid it)?
Thanks,
Nick
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: RegEx on 4MB file consumes of 2GB of ram before windows shuts it down.
by xdg (Monsignor) on Apr 12, 2004 at 15:42 UTC | |
by Ardemus (Beadle) on Apr 12, 2004 at 17:28 UTC |