2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-09-05 09:05:40 +00:00
Files
bind/lib/isc/meminfo.c
Ondřej Surý 06e5ada4be Use libuv functions to get memory available to BIND 9
This change uses uv_get_total_memory() to get the memory available to
BIND 9 with possible modification by uv_get_constrained_memory() if the
libuv version is recent enough to honour constraints created by
f.e. cgroups.
2024-09-24 15:51:14 +02:00

30 lines
788 B
C

/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
*
* SPDX-License-Identifier: MPL-2.0
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
*
* See the COPYRIGHT file distributed with this work for additional
* information regarding copyright ownership.
*/
#include <inttypes.h>
#include <isc/meminfo.h>
#include <isc/uv.h>
uint64_t
isc_meminfo_totalphys(void) {
uint64_t tmem = uv_get_total_memory();
#if UV_VERSION_HEX >= UV_VERSION(1, 29, 0)
uint64_t cmem = uv_get_constrained_memory();
if (cmem > 0 && cmem < tmem) {
return (cmem);
}
#endif /* UV_VERSION_HEX >= UV_VERSION(1, 29, 0) */
return (tmem);
}