I have been writing a sketch that runs a small web server from the arduino uno. This seems to work just great, except, without any warnings or other indications, the program seems to suffer from some sort of memory use issue during upload if I try to add in just one more line of code. The overall program size is around 14K, out of a max of 32k. The additional code should not be using up the limited SRAM, but maybe it is.
In the program there are a number of lines that use client.print to serve up some HTML. An example of them is shown below. If I don’t comment out any one of these four working lines of good code the program compiles, and then uploads, but rather than serving up the web page, it shoots fast jibberish out the serial monitor port back to the PC, rather than the expected network activity. It doesn’t matter which line is commented out. No errors when compiling, no errors when uploading. That is the puzzle, which is leading me to think it is a memory issue, and since it is less than the flash available, its likely SRAM. They all work fine provided that they are all not in the sketch at the same time.
So, here are some simple questions,
How do I figure out the memory utilization for the SRAM? Is there a memory map file being stored some place? Is there an assembly listing file available to aid in debug?
Are the strings in the client.print, being stored in SRAM or are they being loaded from flash. They are constants, so i would have expected the underlying code to use a pointer to the flash, however it is possible that it is storing these in SRAM, all at once, rather than bringing them one at at time when the line of code is actually being executed.
If I am running out of SRAM, is there any easy way to find out? The monitor goes out to lunch when I uncoment any of the additional lines.
is there any way to direct the ARduino to force storage of constants in flash, so that the memory can be better managed, or at least understood?
The program also uses an X10firecracker library and its associated lower level .h files, such as wiring.h (Not wire.h).
Suggestions on how to resolve and debug this would be great. A snipet of the issue is below.
// client.println(” “);