简体   繁体   中英

Shutting Down program if the memory exceeded a certain limit - c++/Qt

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"

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM