Electrical – How much RAM do I have for dynamic memory allocation in the Nios II


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?

Best Answer

You should know this because you built the NOIS processor and had to specify the size of the ram to make the processor. Its whatever you allocated in NIOS, which is stored in a constant in system.h in the BSP generated files.

Malloc will return NULL if it hits the end of the memory space.