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

Function limitSystemMemory

src/utils/memory.cpp:209–223  ·  view source on GitHub ↗

* @brief Limits system memory to the given size (in bytes). * * @return @c true if the limiting succeeded, @c false otherwise. * * When @a limit is @c 0, it immediately returns @c false. * * This function is not reentrant, i.e. it is not safe to call it simultaneously * from multiple threads. */

Source from the content-addressed store, hash-verified

207* from multiple threads.
208*/
209bool limitSystemMemory(std::size_t limit) {
210 if (limit == 0) {
211 return false;
212 }
213
214#ifdef OS_WINDOWS
215 return limitSystemMemoryOnWindows(limit);
216#elif defined(OS_MACOS)
217 return limitSystemMemoryOnMacOS(limit);
218#elif defined(OS_BSD)
219 return limitSystemMemoryOnBSD(limit);
220#else
221 return limitSystemMemoryOnLinux(limit);
222#endif
223}
224
225/**
226* @brief Limits system memory to half of the total memory.

Callers 6

processArgsFunction · 0.85
TearDownMethod · 0.85
TEST_FFunction · 0.85

Calls 4

limitSystemMemoryOnMacOSFunction · 0.85
limitSystemMemoryOnBSDFunction · 0.85
limitSystemMemoryOnLinuxFunction · 0.85

Tested by 2

TearDownMethod · 0.68
TEST_FFunction · 0.68