Possible Bug with arrays?

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

Possible Bug with arrays?

Post by AndT »

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: 3096
Joined: Jan 15, 2007 20:44
Location: Australia

Re: Possible Bug with arreys?

Post by Richard »

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: 7983
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Possible Bug with arrays?

Post by dodicat »

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: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: Possible Bug with arreys?

Post by TJF »

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?

Post by Destructosoft »

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)
Post Reply