Possible Bug with arrays?

General FreeBASIC programming questions.
AndT
Posts: 26
Joined: Aug 01, 2007 10:05

Possible Bug with arrays?

Postby AndT » Sep 03, 2012 11:27

Code: Select all

dim a (1 to 1024,0 to 768) as ubyte
dim b (1 to 1024,0 to 768) as ubyte

I can't debug this because it is simply crashing by all what i do.

Version: 0.24.0 (WIN32)
Richard
Posts: 2944
Joined: Jan 15, 2007 20:44
Location: Australia

Re: Possible Bug with arreys?

Postby Richard » Sep 03, 2012 11:48

Your arrays are too big for the stack. Increase the stack size or make them shared.

Code: Select all

Dim Shared a (1 To 1024,0 To 768) As Ubyte
Dim Shared b (1 To 1024,0 To 768) As Ubyte
dodicat
Posts: 5828
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Possible Bug with arrays?

Postby dodicat » Sep 03, 2012 11:59

Going above the stack limit I reckon.
Better not to use the stack by using shared:

Code: Select all

dim shared a (1 to 1024,0 to 768) as ubyte
dim shared b (1 to 1024,0 to 768) as ubyte

print "Stack used without Shared ",(2*1024*769 *sizeof(ubyte)/1024)/1024 & "  Mb"
print "Default Stack ",1 & " Mb"

sleep
 
TJF
Posts: 3473
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: Possible Bug with arreys?

Postby TJF » Sep 03, 2012 16:13

Richard wrote:Your arrays are too big for the stack. Increase the stack size or make them shared.

An other solution is to use STATIC (if you don't want the arrays to be SHARED)

Code: Select all

STATIC a (1 To 1024,0 To 768) As Ubyte
STATIC b (1 To 1024,0 To 768) As Ubyte
Destructosoft
Posts: 88
Joined: Apr 03, 2011 3:44
Location: Inside the bomb
Contact:

Re: Possible Bug with arrays?

Postby Destructosoft » Sep 04, 2012 0:02

Or use ReDim:

Code: Select all

dim as ubyte a(),b()
redim as ubyte a(1 to 1024,0 to 768),b(1 to 1024,0 to 768)

Return to “General”

Who is online

Users browsing this forum: No registered users and 3 guests