5 ms·
There's gotta be some way to programmatically determine it, right? It may not be portable. It may require some system calls or something, but there's gotta be a
by one_off_comment 5y ago
There's gotta be some way to programmatically determine it, right? It may not be portable. It may require some system calls or something, but there's gotta be a way, right?
- wmf 5y agoI guess you could mlock() your memory and see if that succeeds or fails. When overcommit is enabled no memory is really safe.
- yjftsjthsd-h 5y agoI'm not an expert enough to tell you; I just read the article and decided that it was too long so summarized for others. There's some discussion upthread about catching SIGSEGV and other methods, FWIW.
- TillE 5y agoThe question is what problem are you actually trying to solve. You can get away with just about anything if you do it in a child worker process which can safely crash.
- matheusmoreira 5y agoMaybe a system call that checks whether writing to a page would result in a fault? What if we had memory file descriptors for pages? We'd be able to use them with epoll and io_uring to asynchronously check whether it's safe to write to the pages they represent.