in reply to Re: RegEx on 4MB file consumes of 2GB of ram before windows shuts it down (Memory Leak in 5.8.2)
in thread RegEx on 4MB file consumes of 2GB of ram before windows shuts it down (Memory Leak in 5.8.2)

I'm actually working on a rather complex module to handle this type of thing. I guess I gave the impression that a sound entry was the only type of data object in the file. In fact it is a self referential nested tree with many types of objects...

:)

I could, however, slurp a line at a time until the line was ^\s*Sound$ then make sure the next line was correct, check if the name matched (and steal the white space). Finally I'd check the next line and either add a priority line or update it. I could write each line right back out to the output file as I go.

That's a much better approach and much less prone to bugs (and it would work around the reg-ex memory leak in 5.8.2).

Thanks

  • Comment on Re: Re: RegEx on 4MB file consumes of 2GB of ram before windows shuts it down (Memory Leak in 5.8.2)
  • Download Code

Replies are listed 'Best First'.
Re: Re: Re: RegEx on 4MB file consumes of 2GB of ram before windows shuts it down (Memory Leak in 5.8.2)
by tachyon (Chancellor) on Apr 13, 2004 at 08:23 UTC

    You don't parse self referential nested trees with simple REs. You parse them with a parser (typically recursive descent) and then work over the nodes.

    Regardless of that the code I supplied does the same as the regexes you were trying to use in your original post except a lot more efficiently. You seem to have missed what it does. Also you seem happy to blame a memory leak in the RE engine. Besides the fact that your REs are really rather badly written I pointed out you have an extra set of braces:

    while(<>) { { # surplus to requirements

    this may well be creating a closure.

    cheers

    tachyon