| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | |
| 3 | #include "mmap_limit.h" |
| 4 | #include "libnetdata/libnetdata.h" |
| 5 | |
| 6 | unsigned long long os_mmap_limit(void) { |
| 7 | static unsigned long long cached_limit = 0; |
| 8 | |
| 9 | if (cached_limit) |
| 10 | return cached_limit; |
| 11 | |
| 12 | #if defined(OS_LINUX) |
| 13 | if(read_single_number_file("/proc/sys/vm/max_map_count", &cached_limit) != 0) |
| 14 | cached_limit = 65536; |
| 15 | #else |
| 16 | // For other operating systems, assume no limit. |
| 17 | cached_limit = UINT32_MAX; |
| 18 | #endif |
| 19 | |
| 20 | return cached_limit; |
| 21 | } |