The program may be stored in on chip memory or off chip memory but like any processor, the processor RAM will be on chip. All dynamic memory allocation shall be carried out using this RAM.
How do I know how much RAM I have in my design? I know that we may keep doing malloc and check if memory has run out. However, is there a way to know in advance as to how much total memory there really is?