* @brief Implementation of @c limitSystemMemory() on POSIX-compliant systems. */
| 33 | * @brief Implementation of @c limitSystemMemory() on POSIX-compliant systems. |
| 34 | */ |
| 35 | bool 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 |
no outgoing calls
no test coverage detected