[fxruby-users] is there a memory limitation on fxruby-mswin32 ?

Lyle Johnson lyle at lylejohnson.name
Mon Aug 11 08:21:15 EDT 2008


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







More information about the fxruby-users mailing list