There are problems on many accounts: you can forget all the dance around the heap, — malloc can (it sometimes will) just use mmap; catching malloc is not enough, you can directly mmap, or, and there's perfectly a fine stack you can utilize for 1M; you cannot restrict memory space because necessary libraries take considerate to 1M amount.
TL;DR: 1M is too small to do it.