How much Ram/EEPOM resources are used in a sketch?

I am a newb

How much Ram/EEPROM resources are used in a sketch?
How can I find out because the only message, when compiling a sketch, is the flash that is used?

No EEPROM is used. This post on another forum provides a function you can call on your mega168 to figure out how much free RAM you have at any point in your sketch:

http://forum.pololu.com/viewtopic.php?f=10&t=989&p=4218#p4218

The function uses the global variables that track the end of the heap (or the end of the globals, if no memory has been dynamically allocated) and compares them to the position in RAM of a local variable, which should be pretty much on top of the stack. Since the stack grows from the end of RAM inward and the heap grows from the end of the globals outwards, your free space is the gap between the top of the heap and the top of the stack.

Typically you want to know a worst-case for your RAM usage, so you should call this function in one of your most deeply nested functions, or in a function that declares a lot of local variables. If you still have plenty of space, you can be fairly confident that your stack will not overrun your heap/globals.

If you just want to ballpark it, know that the Arduino allocates a 128-byte array for storing received serial data, and it uses a few other globals here and there for various library functions. So right off the bat you can estimate that you maybe have 850 - 875 bytes of RAM for your globals, heap, and stack. Subtract from this your globals and any memory you dynamically allocate, and this is what you have left over for your stack. You should probably leave more room for your stack than you think need (stack overflow errors can lead to some frustrating problems and very strange failures).

  • Ben

If you just want to ballpark it, know that the Arduino allocates a 128-byte array for storing received serial data, and it uses a few other globals here and there for various library functions. So right off the bat you can estimate that you maybe have 850 - 875 bytes of RAM for your globals, heap, and stack. Subtract from this your globals and any memory you dynamically allocate, and this is what you have left over for your stack. You should probably leave more room for your stack than you think need (stack overflow errors can lead to some frustrating problems and very strange failures).

And don't forget that any libraries that your sketch may include will also consume memory.