As cgroups (and possibly other kernel-level resource limits) may specify a limit on the amount of memory a process can consume, it would be useful for this library to expose an API like uv_get_usable_memory (in addition to total and free). Node.js would be able to then use this to set a memory limit for V8 isolates (see nodejs/node#27508).
I've put something together for linux/cgroups here. I wanted to get feedback before taking time to flesh it out more. In particular, I think if we introduce this API, that we could iteratively implement it for other OS's besides Linux, and in the meantime just return a very high value as a place holder (cgroups itself uses a value of 0x7FFFFFFFFFFFF000 to represent no memory limit).
As cgroups (and possibly other kernel-level resource limits) may specify a limit on the amount of memory a process can consume, it would be useful for this library to expose an API like
uv_get_usable_memory(in addition tototalandfree). Node.js would be able to then use this to set a memory limit for V8 isolates (see nodejs/node#27508).I've put something together for linux/cgroups here. I wanted to get feedback before taking time to flesh it out more. In particular, I think if we introduce this API, that we could iteratively implement it for other OS's besides Linux, and in the meantime just return a very high value as a place holder (cgroups itself uses a value of
0x7FFFFFFFFFFFF000to represent no memory limit).