Flash vs Sram

Hi,

Can someone please expalin to me how the Arduino decides on flash or Sram?
e.g. I have written a 4k program to the atmel328P which has 32k flash, 2k Sram & 1k EEprom.

The IDE shows the amount of flash available but the code runs in Sram. I need some clarification on this isue.

Thanks.

but the code runs in Sram

Not possible, I'm afraid - why do you think that?

The AVR is a Harvard architecture (unlike your PC's von Neumann architecture), with completely separate program memory (flash) and RAM spaces.
It is not possible to execute code from RAM.
The word sizes are different in any case.

So I can only concentrate on the Flash to run my prgram. Where does the Sram come into play?

Flash is ROM (read-only memory), so is used for program code, RAM (random access memory (read/write memory)) is used for variables, stack, heap etc.

How would I know how much ram and how much flash gets used by my program?

The IDE tells you how much flash; telling how much RAM is trickier.

Have a look around the forum, this subject only comes up about once every week.

Thank you.