fix compiler errors

This commit is contained in:
Alex Cope 2023-06-29 14:58:08 -07:00 committed by Malavan Sotheeswaran
parent 87012bf98e
commit ac7e6c0691
2 changed files with 9 additions and 6 deletions

View File

@ -36,6 +36,9 @@
#include <mutex>
#include <map>
#include <math.h>
#ifdef __linux__
#include <sys/sysinfo.h>
#endif
/* ----------------------------------------------------------------------------
* Data structures
@ -426,14 +429,14 @@ int getMaxmemoryState(size_t *total, size_t *logical, size_t *tofree, float *lev
maxmemory = static_cast<size_t>(maxmemory*1.2);
/* If free system memory is below a certain threshold, force eviction */
size_t sys_free_mem_buffer;
long sys_free_mem_buffer;
if (g_pserver->force_eviction_percent && g_pserver->cron_malloc_stats.sys_total) {
float free_mem_ratio = (float)(100 - g_pserver->force_eviction_percent)/100;
size_t min_free_mem = static_cast<size_t>(g_pserver->cron_malloc_stats.sys_total * free_mem_ratio);
sys_free_mem_buffer = static_cast<size_t>(g_pserver->cron_malloc_stats.sys_free - min_free_mem);
sys_free_mem_buffer = static_cast<long>(g_pserver->cron_malloc_stats.sys_free - min_free_mem);
if (sys_free_mem_buffer < 0) {
size_t mem_threshold = static_cast<size_t>(mem_reported + sys_free_mem_buffer);
maxmemory = (maxmemory < mem_threshold) ? maxmemory : mem_threshold;
long mem_threshold = mem_reported + sys_free_mem_buffer;
maxmemory = (maxmemory < mem_threshold) ? maxmemory : static_cast<size_t>(mem_threshold);
}
}

View File

@ -2314,7 +2314,7 @@ void cronUpdateMemoryStats() {
if (!g_pserver->cron_malloc_stats.allocator_allocated)
g_pserver->cron_malloc_stats.allocator_allocated = g_pserver->cron_malloc_stats.zmalloc_used;
#ifdef __linux__
#ifdef __linux__
if (g_pserver->force_eviction_percent) {
struct sysinfo sysinf;
memset(&sysinf, 0, sizeof sysinf);