diff --git a/src/core/core.cpp b/src/core/core.cpp index eb261c4b0..0e45db065 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -11,13 +11,25 @@ #include #ifdef __linux__ +#include +#ifndef __ANDROID__ #include -#include // Required for madvise +#endif #endif #ifdef _WIN32 +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#ifndef NOMINMAX +#define NOMINMAX +#endif #include #include + +#undef GetCurrentTime +#undef ERROR +#undef GetMessage #endif #include "audio_core/audio_core.h" @@ -495,11 +507,16 @@ struct System::Impl { if (device_memory) { #ifdef __linux__ - // Use BackingBasePointer() to get the raw pointer madvise(device_memory->buffer.BackingBasePointer(), device_memory->buffer.backing_size, MADV_DONTNEED); + + // Only call malloc_trim on non-Android Linux (glibc) + #ifndef __ANDROID__ malloc_trim(0); + #endif + + // Give the kernel time to update /proc/stats + std::this_thread::sleep_for(std::chrono::milliseconds(20)); #elif defined(_WIN32) - // Use BackingBasePointer() here as well VirtualAlloc(device_memory->buffer.BackingBasePointer(), device_memory->buffer.backing_size, MEM_RESET, PAGE_READWRITE); #endif }