* @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. */
| 207 | * from multiple threads. |
| 208 | */ |
| 209 | bool 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. |