FLTK logo

Re: [fltk.general] Crash due to memory allocation?

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.general  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Re: Crash due to memory allocation? Greg Ercolano Mar 28, 2007  
 
Iain Staffell wrote:
class Pictar..
[..]
private:
	double img[600][600];

	Gahh. sizeof(double) is typically what, 8 bytes..
	So 8 x 600 x 600 = 2.8MB, all that allocated on the stack? Yikes.

MacArthur, Ian (SELEX) (UK) wrote:
You are creating your Pictar widget on the stack, and there is
insufficient stack space in your runtime environment to support that.

Either increase you stack space (bad) or create the widget on the heap
by "new"ing it (good)...

	So true.. that's a lot of stack space.

	If you really want to be able to create the widget on the stack,
	then at least change the class so that img is a pointer that is
	dynamically allocated in the ctor with 'new' or 'malloc()',
	instead of as a hard coded array.

	You'll probably need that anyway so that different image sizes
	can be handled.


Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.