I am currently writing a program that allocates memory in various places. I am interested in seeing how my program behaves when the heap runs out of memory, namely when when malloc() returns NULL.

Is there a compiler option that can let me set the heap size to something very small so I can see what happens immediately? I am using the gcc compiler.