Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Data section exceeds available space in board

Status
Not open for further replies.

Justinli

Member level 4
Member level 4
Joined
Apr 29, 2021
Messages
76
Helped
0
Reputation
0
Reaction score
2
Trophy points
8
Activity points
413
I'm making a small game recently and I want to use Arduino to do it. My code compiles without problems, but when I upload it, I get an error like the one shown in the picture, is it because I have too many variables defined?
Can someone please tell me how to fix it? I didn't expect to get an error in the final upload.
Code:
Arduino:1.8.12 (Windows 10), Development board: "Arduino Uno"

The project uses 6336 bytes, which occupies (19%) of the program storage space. The maximum is 32256 bytes. data section exceeds available space in board

Global variables used 3046 bytes, (148%) of dynamic memory, leaving -998 bytes for local variables. The maximum is 2048 bytes.
There is not enough memory; visit the following URL to follow the instructions to reduce memory usage.
http://www.arduino.cc/en/Guide/Troubleshooting#size
Error while compiling for development board Arduino Uno.

Turn on in File -> Preferences
"Show detailed output during compilation" option
This report will contain more information.
 

Hi,

Global variables used 3046 bytes, (148%) of dynamic memory, leaving -998 bytes for local variables. The maximum is 2048 bytes.
I think it's rather clear. You defined 3046 bytes of global variables, but only 2048 bytes are available.

Define them as local variables, where possible.
Or use an Arduino with more SRAM.

Klaus
 

Hi,


I think it's rather clear. You defined 3046 bytes of global variables, but only 2048 bytes are available.

Define them as local variables, where possible.
Or use an Arduino with more SRAM.

Klaus
I would like to know if there is a solution without replacing the board?
 

I think you are confused over the program memory and the data memory. There is plenty of program memory space but not enough data memory.
Without seeing your code it isn't possible to be sure of a solution but if some of your data is in the form of fixed text or tables of data (as opposed to variables that change as the program runs) you could consider moving them into the program memory space by declaring them 'const'.

Brian.
 

To store a constant in flash memory instead of RAM on an Arduino, use the PROGMEM directive, as in the example below:

Code:
const char days[7][4] PROGMEM = {"Sun","Mon","Tue","Wed","Thu","Fri","Sat"};

To read data stored in flash memory use a function such as:

Code:
pgm_read_byte(days[x][y])
 
Last edited:

Thanks for your replies, I'll put some of my code below hoping you can find the specific problem.
Code:
  case 56:
        if((r_flag1 == 0)&&(RecievedTemp1[14]==2))
        {
        Serial.println("ST<{\"cmd_code\":\"set_image\",\"type\":\"image\",\"widget\":\"image9\",\"image\":\"circle\"}>ET");
        r_flag1 = 1;
        quan_hang3++;
            quan_lie2++;
            Serial.println("ST<{\"cmd_code\":\"set_enable\",\"type\":\"widget\",\"widget\":\"button8\",\"enable\":false}>ET");
        }
        else if((r_flag1 == 1)&&(RecievedTemp1[14]==2))
        {
          Serial.println("ST<{\"cmd_code\":\"set_image\",\"type\":\"image\",\"widget\":\"image9\",\"image\":\"x\"}>ET");
         r_flag1 = 0;
         cha_hang3++;
           cha_lie2++;
           Serial.println("ST<{\"cmd_code\":\"set_enable\",\"type\":\"widget\",\"widget\":\"button8\",\"enable\":false}>ET");
        }
        break;       
  case 57:
        if((r_flag1 == 0)&&(RecievedTemp1[14]==2))
        {
        Serial.println("ST<{\"cmd_code\":\"set_image\",\"type\":\"image\",\"widget\":\"image10\",\"image\":\"circle\"}>ET");
        r_flag1 = 1;
        quan_hang3++;
            quan_lie3++;
            quan_youxia++;
            Serial.println("ST<{\"cmd_code\":\"set_enable\",\"type\":\"widget\",\"widget\":\"button9\",\"enable\":false}>ET");
        }
        else if((r_flag1 == 1)&&(RecievedTemp1[14]==2))
        {
          Serial.println("ST<{\"cmd_code\":\"set_image\",\"type\":\"image\",\"widget\":\"image10\",\"image\":\"x\"}>ET");
         r_flag1 = 0;
         quan_hang3++;
           quan_lie3++;
            quan_youxia++;
            Serial.println("ST<{\"cmd_code\":\"set_enable\",\"type\":\"widget\",\"widget\":\"button9\",\"enable\":false}>ET");
 


Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top