Hi,

i have a library which uses mmap to map big files into memory. At some point, mmap fails with ENOMEM. And from what i understand, mmap uses kernel memory which is limited per system (not per process).

I have some questions related to this...

1. How can i know the system limit of memory available to mmap?
I think it is setrlimit(2) with RLIMIT_AS - can you pls confirm if that is true?

2. How can i know the current usage of this memory? I want to fallback to malloc/read as soon as a certain threshold is passed (i.e. 75% of the available memory).

Thanks
Christoph