On 3-Dec-06, at 8:59 PM, Yukihiro Matsumoto wrote: > Hi, > > In message "Re: Segmentation fault, proc, eval, long string > [Reproduced]" > on Sun, 3 Dec 2006 22:51:38 +0900, Bob Hutchison > <hutch / recursive.ca> writes: > > |> Thank you for the report. Your script helped. Could you check > if the > |> attached patch work for you? > | > |Thanks for the patch. I applied it and tried a few things with it. > |The test program I provided does work now, so I think this is solving > |the problem. On the other hand, when I try to run the application > |that needs it, debian is killing it and I can't see why. The > |installation I'm using, as it happens, doesn't have any VM configured > |and this has been causing some difficulty recently. Could this patch > |cause a lot of memory to be allocated rapidly? If not then there's > |something else going on that I'll have to look into (and it is likely > |a completely different problem). > > The patch does rather decrease the amount of memory that Ruby use. > But the original program seems to use tens of thousands of in-block > variables, which themselves consumes more memory than plain local > variables or arrays. So by avoiding segmentation fault, it turns out > to kick the out-of-memory killer of linux kernel. > > If it's possible, I'd recommend you to reduce these local variables. This is consistent with what I'm seeing. Just before you posted your patch, I made a couple of changes to the application and also replaced the Proc with a method. The changes to the application would reduce the maximum number of local variables by typically one third. The use of a method rather than a Proc avoided the nested parsing and subsequent stack overflow (and is many times faster for large cases). Even with that the application barely fits into the available memory. So if the Proc's local variables cause even a relatively small proportional increase in memory the application is going to get itself killed. Anyway, with the combination of all of this, and a better linux configuration I think I'll be past this. Thanks again to everyone for your help. Cheers, Bob > > matz. > ---- Bob Hutchison -- blogs at <http://www.recursive.ca/ hutch/> Recursive Design Inc. -- <http://www.recursive.ca/> Raconteur -- <http://www.raconteur.info/> xampl for Ruby -- <http://rubyforge.org/projects/xampl/>