setrlimit

How can I limit memory acquired with `malloc()` without also limiting stack?

I'm trying to keep student code from running wild with allocations and dragging my test machine to a halt. I've tried setrlimit(RLIMIT_DATA, r); where r is a struct holding the limits. But unfortunately although this limit stops brk and sbrk from allocating, the C library just fails over to mmap and keeps right on allocating. I've ...