Erdwin Lianata
2008-Aug-11 04:26 UTC
[fxruby-users] is there a memory limitation on fxruby-mswin32 ?
Hi All, I wonder is there a memory limitation on fxruby-mswin32 ? I build an application which uses a lot of checkboxes, it seems running well on Linux...but it crashes on Windows. Would you please try to run the following code... ========= HERE IS THE CODE =======require ''fox16'' include Fox class CheckersView < FXMatrix def initialize(parent) super(parent, 10, :opts => MATRIX_BY_COLUMNS) 5.times { 10.times { FXCheckButton.new(self, '''', :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y) } } end end class TestView < FXMainWindow def initialize(app) super(app, ''Test Memory App'', :opts => DECOR_ALL, :width => 600, :height => 600) vframe = FXVerticalFrame.new(self, LAYOUT_FILL) FXButton.new(vframe, ''Add'') do |button| button.connect(SEL_COMMAND) do add_table(@frame, true) @frame.parent.layout puts "add_table" end end @counter = 1 FXScrollWindow.new(vframe, LAYOUT_FILL) do |scroll| @frame = FXVerticalFrame.new(scroll, LAYOUT_FILL) 93.times { add_table(@frame) } end end def add_table(table_parent, with_create=false) vframe = FXVerticalFrame.new(table_parent) label = FXLabel.new(vframe, @counter.to_s) matrix = FXMatrix.new(vframe, 3, :opts => MATRIX_BY_COLUMNS) CheckersView.new(matrix) FXVerticalFrame.new(matrix) CheckersView.new(matrix) vframe.create if with_create @counter += 1 end def create super show(PLACEMENT_SCREEN) end end FXApp.new do |app| TestView.new(app) app.create app.run end ========= END OF CODE ======= Here I create 93 rows whose each row has 2 table and each table consists of 50 checkboxes. At the topmost of window is a button that is intended to add a new row. The application will crash if the total of rows reach 95. Sometimes it gives a "[BUG] Segmentation fault" messsage which points to FXMatrix''s constructor (kwargs.rb). But sometimes it will silently hang, at this moment you can check that the output of "add_table" isn''t printed even though the button was clicked. My Windows spesifications are RubyOneClickInstaller-1.8.26 and lib FXRuby-1.6.12 which come along with the installer. I can run the code on Linux, I even can test it with given 150 rows and it''s still running well. My Linux specifications are Ruby-1.8.5 and installed gem fxruby-1.6.15. Any workaround for this issue? Thanks, Erdwin
Lyle Johnson
2008-Aug-11 12:21 UTC
[fxruby-users] is there a memory limitation on fxruby-mswin32 ?
On Aug 10, 2008, at 11:26 PM, Erdwin Lianata wrote:> I wonder is there a memory limitation on fxruby-mswin32 ? > I build an application which uses a lot of checkboxes, it seems > running > well on Linux...but it crashes on Windows.<snip>> Here I create 93 rows whose each row has 2 table and each table > consists > of 50 checkboxes. At the topmost of window is a button that is > intended > to add a new row. The application will crash if the total of rows > reach 95. > Sometimes it gives a "[BUG] Segmentation fault" messsage which > points to > FXMatrix''s constructor (kwargs.rb). But sometimes it will silently > hang, > at this moment you can check that the output of "add_table" isn''t > printed even though the button was clicked.There is no limitation in the FXRuby code, but you may be running into some limitation of the Windows OS; see for example this article: http://support.microsoft.com/kb/327699 Let''s focus on the add_table() method from your program: def add_table(table_parent, with_create=false) vframe = FXVerticalFrame.new(table_parent) label = FXLabel.new(vframe, @counter.to_s) matrix = FXMatrix.new(vframe, 3, :opts => MATRIX_BY_COLUMNS) CheckersView.new(matrix) FXVerticalFrame.new(matrix) CheckersView.new(matrix) vframe.create if with_create @counter += 1 end Each CheckersView uses up 51 windows handles (one for the matrix, plus 50 more for the checkboxes). In add_table() I see: vframe (1) + label (1) + matrix (1) + CheckersView (51) + vertical frame (1) + CheckersView (51) = 106 So that makes 106 window handles used per call to add_table(), and if we call it 93 times: 106*93 = 9,858 window handles which is awfully close to the 10,000 handles limit mentioned in the article that I linked to.> Any workaround for this issue?I''m having trouble imagining why you''d want 930 checkboxes on the screen at the same time; that seems like an awful lot of information to present to the user at once. If there''s some way to restructure the user interface so that you can create some of those checkboxes on demand, and show them only when they''re actually needed. Hope this helps, Lyle --- "FXRuby: Create Lean and Mean GUIs with Ruby" Now available from the Pragmatic Bookshelf! http://www.pragprog.com/titles/fxruby
Erdwin Lianata
2008-Aug-12 09:11 UTC
[fxruby-users] is there a memory limitation on fxruby-mswin32 ?
Lyle Johnson wrote:> I''m having trouble imagining why you''d want 930 checkboxes on the screen > at the same time; that seems like an awful lot of information to present > to the user at once. If there''s some way to restructure the user > interface so that you can create some of those checkboxes on demand, and > show them only when they''re actually needed.Thanks Lyle, it solves my problem at this moment (though only 18,000 maximum number of handles is supported by the hotfix). Since I''m not a Windows user, I thought that problem was a portability issue of fxruby. Anyway, I''m actually creating an statistical application that needs a set of checkboxes to give user a table-like input (only on/off switch) to filter out each computation result. That''s why I need to create a lot of checkboxes at the same time, it''s not possible to show only partial of them. I have one more question, is there a way to remove "handle" for a widget? Widgets such as label, vertical/horizontal frame, and only-display widgets no need to receive a user response (in my app). So I can reduce the number of handle. Thanks, Erdwin
Lyle Johnson
2008-Aug-12 14:25 UTC
[fxruby-users] is there a memory limitation on fxruby-mswin32 ?
On Tue, Aug 12, 2008 at 4:11 AM, Erdwin Lianata <erdwin.lianata at yahoo.com.sg> wrote:> I have one more question, is there a way to remove "handle" for a widget? > Widgets such as label, vertical/horizontal frame, and only-display widgets > no need to receive a user response (in my app). So I can reduce the number > of handle.No. Even windows that are display-only (like labels and frames) always have an associated window handle.
Philippe Lang
2008-Aug-12 15:21 UTC
[fxruby-users] is there a memory limitation on fxruby-mswin32 ?
fxruby-users-bounces at rubyforge.org wrote:> Lyle Johnson wrote: >> I''m having trouble imagining why you''d want 930 checkboxes on the >> screen at the same time; that seems like an awful lot of information >> to present to the user at once. If there''s some way to restructure >> the user interface so that you can create some of those checkboxes on >> demand, and show them only when they''re actually needed. > > Thanks Lyle, it solves my problem at this moment (though only 18,000 > maximum number of handles is supported by the hotfix). Since I''m not > a Windows user, I thought that problem was a portability issue of > fxruby. > > Anyway, I''m actually creating an statistical application that needs a > set of checkboxes to give user a table-like input (only on/off > switch) to filter out each computation result. That''s why I need to > create a lot of checkboxes at the same time, it''s not possible to > show only partial of them.Hi, Instead of creating so many checkboxes, you could maybe use an FXTable object, and process the clicks inside cells in order to toggle an icon inside. That''s a little more work, but you shouldn''t have any limitation in this case. That''s what I do in my framework. Regards, Philippe Lang