MCPcopy Create free account
hub / github.com/avast/retdec / limitSystemMemoryOnPOSIX

Function limitSystemMemoryOnPOSIX

src/utils/memory.cpp:35–42  ·  view source on GitHub ↗

* @brief Implementation of @c limitSystemMemory() on POSIX-compliant systems. */

Source from the content-addressed store, hash-verified

33* @brief Implementation of @c limitSystemMemory() on POSIX-compliant systems.
34*/
35bool limitSystemMemoryOnPOSIX(std::size_t limit) {
36 struct rlimit rl = {
37 .rlim_cur = static_cast<rlim_t>(limit), // Soft limit.
38 .rlim_max = RLIM_INFINITY // Hard limit (ceiling for rlim_cur).
39 };
40 auto rc = setrlimit(RLIMIT_AS, &rl);
41 return rc == 0;
42}
43
44#endif
45

Callers 2

limitSystemMemoryOnBSDFunction · 0.85
limitSystemMemoryOnLinuxFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected