1

当我尝试将模块包含到 Ruby-Processing 草图中时,它返回以下 StackOverflowError:

matt$ rp5 run cylinder_test.rb
matt$ Error: Your application used more stack memory than the safety cap.
Specify -J-Xss####k to increase it (#### = cap size in KB).
Specify -w for full StackOverflowError stack trace

使用 -w 运行草图不提供额外信息。

模块 Cylinder 包括Processing::Proxy模块,以便访问 begin_shape 和 end_shape 方法等。我尝试将方法定义为类方法和实例方法(在方法定义之前有和没有“self.”)。

module Cylinder
    include Processing::Proxy
    def self.cylinder( sides, r1, r2, h )
...

我尝试删除“include Processing::Proxy”行,但它只是告诉我有未定义的常量和方法,它们包含在 Processing::Proxy 中。所以这可能不是问题。

我的草图的标题如下所示:

class CylinderTest < Processing::App

    load '../controllers/branch_controller.rb'
    load '../controllers/node_controller.rb'

    require 'Cylinder.rb'
    include Cylinder
...

我应该指出我相信这些方法是有效的,因为当我将 Cylinder 模块本身编写为 Ruby-Processing 草图时,它运行良好。

我正在使用 Ruby-Processing 1.0.11 和 Ruby 1.8.7。

那么,如何在不导致堆栈溢出错误的情况下包含 Cylinder 模块?

4

0 回答 0