I am making a project with Arduino and I want to declare an array with 1,400,000 spots.The compiler spits aout an error message "size of array is too large".It is crucial for my project to hve that big array.
Does anyone know how can I do that?
Any help is appreciated.
You're working with parts that have a few thousand bytes of RAM. If you need storage of 3 orders of magnitude more data, you're going to need to look at external means like an SPI EEPROM or SD card or some such.
I am making a project with Arduino and I want to declare an array with 1,400,000 spots.The compiler spits aout an error message "size of array is too large".It is crucial for my project to hve that big array.
Does anyone know how can I do that?
Any help is appreciated.
Compare that number to the available memory in an Arduino. what do you get?
I am sure the arduino can do such thing because I was able to declare 47 arrays with a size of 30,000
each(47*30,000 = 1,400,000)(all the arrays are of type byte).So I do not need any external memory.I just do not know how to declare one array of size 1,400,000.
ARIS009:
I am sure the arduino can do such thing because I was able to declare 47 arrays with a size of 30,000
each(47*30,000 = 1,400,000)(all the arrays are of type byte).So I do not need any external memory.I just do not know how to declare one array of size 1,400,000.
That is absolute nonsense! I don't know of any Arduino with anywhere near that much memory. There is NO way you actually got such code to compile. More likely the compiler optimized the arrays out because you never referenced them.
Regards,
Ray L.
AVR-GCC is limited to arrays shorter than 32k bytes (which is a bit academic unless you add external RAM, since the largest AVR only has 16k bytes of RAM.)
Which Arduino are you using? I guess a Yun might have 1.4Mbyte+ of RAM, but ... that's the only one.
Of course, you can define very large automatic arrays (up to the limit for an individual array) in huge numbers, and the compiler will not complain, however, if the run time call sequence is such that multiple huge arrays must be present simultaneously, you get a problem.
You fill all those arrays. but never do anything with them. So, the compiler is smart enough to realize the arrays serve no useful purpose, and optimizes them away.
Don't believe me? Add a single loop that READS one of those arrays, and prints it to the Serial Console. THAT code will NOT compile, and the compiler will tell you there is not enough memory.
You really do not understand nearly as much as you seem to believe you do. What you are attempting to do will NEVER work on an Arduino.
ARIS009:
For the ones that do not believe me here is my full code. You can try to compile it yourselfs.
c:/users/sterretje/appdata/local/arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2/bin/../lib/gcc/avr/4.9.2/../../../../avr/bin/ld.exe: address 0x9586b9 of C:\Users\sterretje\AppData\Local\Temp\arduino_build_528596/sketch_jan16a.ino.elf section `.bss' is not within region `data'
c:/users/sterretje/appdata/local/arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2/bin/../lib/gcc/avr/4.9.2/../../../../avr/bin/ld.exe: address 0x9586b9 of C:\Users\sterretje\AppData\Local\Temp\arduino_build_528596/sketch_jan16a.ino.elf section `.bss' is not within region `data'
[b][color=red]collect2.exe: error: ld returned 1 exit status[/color][/b]
exit status 1
Error compiling for board Arduino/Genuino Mega or Mega 2560.
ARIS009:
For the ones that do not believe me here is my full code. You can try to compile it yourselfs.
So that will be everyone then. You have not had a single reply that says you can do this.
Also if you can't help then simply don't post.
Also if you are not prepared to learn then we would appreciate it if you don't post either. We are prepared to help but you are not prepared to be helped.