I’ve got a Ruby app that creates a tree data structure and then
recursively walks that structure to generate some data - that’s the short
description (the longer description has to do with generating test
vectors for finite state machines (FSMs)). It’s been working fine.
Yesterday I decided that I wanted to be able to see what that tree structure
looks like so I decided to use SvgCanvas (see SvgCanvas in the RubyGarden
wiki) which uses dot to generate an svg file and imports it into TkCanvas -
it works pretty nicely, BTW (except for the segfault on large testcases).
After making these additions, it seemed to work fine. But then I tried a
larger testcase (which used to work) that generates a tree with several
hundred nodes and I found that the script segfaults. I turned off the
tree drawing feature thinking that that was the problem, but it still
segfaulted which was odd (as far as I knew the script was back to the
state it was in prior to adding the drawing feature). Then I noticed that
I still had the ‘require “tk”’ at the top of the script. After commenting
that out the problem went away.
Does requiring Tk take a lot of memory or something? Any ideas?
(BTW: TkCanvas is pretty nice as it’s quite easy to get postscript from a
canvas)
Phil
···
–
"Or perhaps the truth is less interesting than the facts?"
Amy Weiss (accusing theregister.co.uk of engaging in ‘tabloid journalism’)
Senior VP, Communications
Recording Industry Association of America
hundred nodes and I found that the script segfaults. I turned off the
tree drawing feature thinking that that was the problem, but it still
segfaulted which was odd (as far as I knew the script was back to the
state it was in prior to adding the drawing feature). Then I noticed that
I still had the ‘require “tk”’ at the top of the script. After commenting
that out the problem went away.
Does requiring Tk take a lot of memory or something? Any ideas?
Which version of Ruby are you using and on which platform?
hundred nodes and I found that the script segfaults. I turned off the
tree drawing feature thinking that that was the problem, but it still
segfaulted which was odd (as far as I knew the script was back to the
state it was in prior to adding the drawing feature). Then I noticed that
I still had the ‘require “tk”’ at the top of the script. After commenting
that out the problem went away.
Does requiring Tk take a lot of memory or something? Any ideas?
Which version of Ruby are you using and on which platform?
ruby 1.6.7 (2002-03-01) [i686-linux-gnu]
I also tried with 1.7.3 on linux and it also segfaulted.
It’s not a huge problem for me right now as I’ve changed the code so that
the require is done after the large tree structure is built and that works
fine - it’s just that anytime there’s a segfault it could be an indicator
that something is rotten somewhere in this case I’m not sure if it’s
in the tk extension or Ruby itself.
One thing to note: The tree structure is built recursively and in this
particular test case the recursion goes pretty deep - could it be some
kind of stack overflow problem?
“Or perhaps the truth is less interesting than the facts?”
Amy Weiss (accusing theregister.co.uk of engaging in ‘tabloid journalism’)
Senior VP, Communications
Recording Industry Association of America