title: How do I reduce the heap size of a program to see how it behaves when it runs out of memory?
body: <p>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.</p>
  
  <p>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.</p>