2

First I searched and found two results , one in which it uses C and didn't really understand , the other is just a different question from mine.

Basically I want to shutdown my program when it exceeds a certain limit , for example 1024kb in "memory"

  • 2
    http://stackoverflow.com/q/63166/1925996 and http://nadeausoftware.com/articles/2012/07/c_c_tip_how_get_process_resident_set_size_physical_memory_use – piedar Sep 15 '14 at 17:38
  • I swear when I searched I didn't find anything except for the two that I've posted about :( , but thanks anyways , I hope I didn't bother anyone ^^ – user3880681 Sep 15 '14 at 17:43

1 Answers1

0

Use this system call. http://linux.die.net/man/2/setrlimit

RLIMIT_AS The maximum size of the process's virtual memory (address space) in bytes. This limit affects calls to brk(2), mmap(2) and mremap(2), which fail with the error ENOMEM upon exceeding this limit. Also automatic stack expansion will fail (and generate a SIGSEGV that kills the process if no alternate stack has been made available via sigaltstack(2)). Since the value is a long, on machines with a 32-bit long either this limit is at most 2 GiB, or this resource is unlimited.