Mega 2560 Free Memory

Hi,

I am using a Mega 2560 for a gps application. The program size is 18,000 bytes and there are 258k byte maximum.

Using:
int ram_info()
{
extern int __heap_start, *__brkval;
int v;
return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);
}

This reports only 6982 bytes free. I would have suspected 200k+. What is correct routine I should be using or does this need modifying?

You have 200k+ of free "program space", which is in flash memory (256kB total.)
ram_info() checks the amount of RAM (data) memory remaining (there is only 8k to start with.)

Here is a very easy to understand overview of the three memory types: