Chris Palmer | 17b41949 | 2018-07-10 00:38:48 | [diff] [blame] | 1 | // Copyright 2018 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef SANDBOX_CONSTANTS_H_ |
| 6 | #define SANDBOX_CONSTANTS_H_ |
| 7 | |
| 8 | #include <limits> |
| 9 | |
| 10 | #include "build/build_config.h" |
| 11 | |
| 12 | namespace sandbox { |
| 13 | |
| 14 | // kDataSizeLimit is used for RLIMIT_DATA on POSIX and for |
| 15 | // JOBOBJECT_EXTENDED_LIMIT_INFORMATION.JobMemoryLimit on Windows. |
| 16 | // |
| 17 | #if defined(ARCH_CPU_64_BITS) |
Eric Lawrence [MSFT] | 0b7f48c | 2021-03-31 22:00:52 | [diff] [blame] | 18 | // Note: On Linux and Windows, the sandbox may set a higher limit for |
| 19 | // renderer and GPU processes if the system has enough physical memory. |
| 20 | constexpr size_t kDataSizeLimit = size_t{1} << 32; // 4 GB |
Chris Palmer | 17b41949 | 2018-07-10 00:38:48 | [diff] [blame] | 21 | #else |
| 22 | // Limit the data memory to a size that prevents allocations that can't be |
| 23 | // indexed by an int. |
Clemens Hammacher | 7a9a0058 | 2019-09-09 09:34:09 | [diff] [blame] | 24 | constexpr size_t kDataSizeLimit = |
Chris Palmer | 17b41949 | 2018-07-10 00:38:48 | [diff] [blame] | 25 | static_cast<size_t>(std::numeric_limits<int>::max()); |
| 26 | #endif |
| 27 | |
| 28 | } // namespace sandbox |
| 29 | |
| 30 | #endif // SANDBOX_CONSTANTS_H_ |