Using win7 and arduino 1.6.7 IDE I have a rather large CONST array of chars and upon compile using atmega2560, it fails and says:

Sketch uses 11,216 bytes (4%) of program storage space. Maximum is 253,952 bytes. Global variables use 8,414 bytes (102%) of dynamic memory, leaving -222 bytes for local variables. Maximum is 8,192 bytes. processing.app.debug.RunnerException: Not enough memory; see http://www.arduino.cc/en/Guide/Troubleshooting#size for tips on reducing your footprint. at cc.arduino.Compiler.size(Compiler.java:319) at cc.arduino.Compiler.build(Compiler.java:156) at processing.app.Sketch.build(Sketch.java:1108) at processing.app.Sketch.build(Sketch.java:1083) at processing.app.Editor$BuildHandler.run(Editor.java:2011) at java.lang.Thread.run(Thread.java:745) Not enough memory; see http://www.arduino.cc/en/Guide/Troubleshooting#size for tips on reducing your footprint.

When I delete the CONST array the program compiles successfully, but when I put it back in, the compiler tells me that I'm using too much dynamic RAM. If I am to understand correctly, consts should store in ROM not RAM.

Here's the even weirder part I put the program in Arduino IDE for Linux and it compiles, but it makes my robot act all crazy.

Any help would be much appreciated.


2 Answers 2


In a Princeton architecture const arrays are stored purely within the text (i.e., flash / read only / ROM) area.

In a Harvard architecture (which is what the Arduino is) the RAM and Flash both use completely different memory spaces, and instructions that work on RAM don't work on Flash, and vice versa.

Because of that it has to copy the const array from Flash into RAM so it can be accessed as normal variables.

To combat this you can use PROGMEM to force it to remain only in Flash, but then you have to use special functions to access the data - you can't use it like normal variables.

You can read more here: https://www.arduino.cc/en/Reference/PROGMEM


Const data may be stored in ROM but the standards don't require it; you usually have to specify in some (non-standard) way that it be placed there. I.e., const-ness is a necessary, but not a sufficient, condition for locating into ROM. Placing Data into ROM with Standard C by Dan Saks is a short, well-written paper (as is typical of Saks) describing what the standards do and, particularly, do not say about ROMming of constant data. It is well worth a few minutes to read it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.