I have a Arduino Uno which is acting up once the memory usage, as reported by the compiler, is over about 28,000 bytes. I know is suppose to have 32k but things start acting strange it seems when I use even just a little over 28k.
I have reduce the Serial.print statements and tried to reduce array sizes, etc which help but it would be nice to know what the usable limit is and if the compiler memory usage is really a good guide to go by.
The figures you're giving are for program storage in flash memory. The flash memory holds the bootloader as well as your sketch so the space available for your sketch will be slightly less than the total size.
Some of the space is required by the bootloader. I think it is 2k or so, so there isn't much room left. Sometimes you hit a brick wall and you are left in no doubt about what is going on, but it is possible to get into a no-man's-land where the programme will load but won't run. I guess you're in this latter category.
The precise size limit probably depends on what the programme does. You already know what the practical limit is.
Get a programmer, and use File:Upload Using Programmer. Take the bootloader space back.
Can move up to a '1284P board. 128K Memory, 16KSRAM. http://www.crossroadsfencing.com/BobuinoRev17/
Thanks for the feedback guys. "Strange" like the Uno will run SETUP, LOOP and then SETUP again and other program flow issues. Sometimes the serial monitor starts showing random characters, the program hangs and the like.
I have already 2 Megas but they are already being used in 2 other projects. I hate to buy another Mega because, except of memory, it is way overkill for my current project, the enomcms type energy monitor. But if I can find another Mega for a good price I'll probably pick one up as I am not done with the energy monitor. I sill want to add outside temp measurement and reporting and I am sure that code will push me over the top for sure of the Uno's memory!
joecatch:
energy monitor. But if I can find another Mega for a good price
One energy monitor is much the same as another and I think it is pretty typical for them to require a Mega. The price difference is about $5 which, for the difference between getting the job done and not getting it done, is very cheap.
like the Uno will run SETUP, LOOP and then SETUP again and other program flow issues.
Try placing the global function from SurferTim in your sketch and call it within the setup() and loop() functions. Sounds like you are clobbering the stack... ouch, that hurts!
Of course, using SurferTIm's function may use even more RAM... smiley-wink
... darn 'catch-22' phrase applied to programming... XD
CrossRoads 1284P board would surely give any UNO program some room... even with RAM leakage, it could take a while to consume 16K. Very nice board, even if the raw 1284P-PU are up over $7 in single quantity.
$7 still way less than a 2560 chip at $18. Or a Mega board at $46 (mouser.com prices).
I should put some kits together, 25-lot or so, get some good pricing that way, $5.11/chip for 1284P.
Just need more hours in a day! Have to check to see how many boards I have on hand.
I installed the code from above and found my SRAM starting at 404 and going down to 187 after the program had run for awhile. I noticed once it got below 200 the program would act up sometimes like either hang or unable to open the SD card. I also found a better way to read an array which was causing problems. With that fix the SRAN drops to 386 and stays there and the program is stable.
I found a "real" (Arduino) Mega 2560 for $35 so I ordered one!
AWOL:
Of course, using SurferTIm's function may use even more RAM...
Only a minimal amount. If that little bit of SRAM use causes a fail, you are in deep poop anyway.
edit: The way I calculate it, it pushes a program counter to the stack and allocates 2 bytes of memory to get the current SRAM position. How much is that?