Re: memory exhausted



On Wed, 11 Apr 2007 02:28:33 +0900, "Luis Parravicini" <lparravi@xxxxxxxxx> wrote:
grepping the ruby source shows regex.c is the only file with that
string. And thats how far I got. Any ideas?

The error is coming from the parser. Here's a simpler test case using integers:

eval <<EOS
case x
#{ (0..2498).map { |n| "when #{n}: nil\n" }.join('') }
end
EOS

We know that it's happening at parse-time rather than run-time, because the out-of-memory error occurs before Ruby has a chance to complain that 'x' is undefined.

In short, the Ruby parser apparently cannot cope with case statements which have more than 2498 branches (at least with the build of Ruby I've got here, changing 2498 to 2497 is enough to avoid the memory issue).

-mental


.



Relevant Pages

  • [SUMMARY] Parsing JSON (#155)
    ... a parser generator to construct their parser. ... def parse ... For String input though, it's often easier to use Ruby's standard StringScanner ... just have each method return the Ruby objects for the JSON it parsed. ...
    (comp.lang.ruby)
  • Re: Using the same subroutine to read files with different structures
    ... to read each line from the external file into a temporary string, ... However, to write a really good parser relying mostly on internal read, there typically isn't enough error reporting granularity in the IOSTAT return codes to do a really proper job of it, not to mention that the IOSTAT values aren't portable. ... returns an array of keyword strings ...
    (comp.lang.fortran)
  • Re: Options handler for userspace programs
    ... One that accepts a string ... Instead, getopt uses: ... can i include environment variable parser for options ... (The argv array ...
    (freebsd-current)
  • Re: Whats right with FORTH and wrong with c.l.f.
    ... I doubt anyone would claim string handling as a Forth forte. ... parsing data in ASCII format *is* a Forth forte. ... to hardcode your parser, ... In Forth land programmer does the job of lexer and parser. ...
    (comp.lang.forth)
  • Re: Parsing JSON (#155)
    ... dataset and I picked the best bandwidth among the 2 longest running ... ruby1.9 killed my LLparser performance. ... l = nil ... out << string ...
    (comp.lang.ruby)

Loading