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

Function limitSystemMemoryOnMacOS

src/utils/memory.cpp:117–134  ·  view source on GitHub ↗

* @brief Implementation of @c limitSystemMemory() on MacOS. */

Source from the content-addressed store, hash-verified

115* @brief Implementation of @c limitSystemMemory() on MacOS.
116*/
117bool limitSystemMemoryOnMacOS(std::size_t limit) {
118 // Warning: We can't limit memory on macOS. Before macOS 12,
119 // limitSystemMemoryOnPOSIX() does not actually do anything on macOS (it
120 // just succeeds). Since macOS 12, it returns an error and RetDec cannot
121 // start. For more details, see
122 // - https://github.com/avast/retdec/issues/379
123 // - https://github.com/avast/retdec/issues/1045
124 //
125 // To be honest, Apple can control memmory limit via a so-called ledger()
126 // system call which is private. An old version which was opened to
127 // OpenSource (from 10.9-10.10?) used setrlimit() but at some point
128 // setrlimit() was broken and not ledger(). Probably in macOS 12
129 // setrlimit() was completely broken.
130 //
131 // Since we do not have any other way of limiting the memory on macOS, just
132 // return true.
133 return true;
134}
135
136#elif defined(OS_BSD)
137

Callers 1

limitSystemMemoryFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected