1
0
mirror of https://github.com/luanti-org/luanti.git synced 2025-10-15 01:25:20 +02:00

Move malloc_trim invocations to background thread (#14744)

This commit is contained in:
sfan5
2024-06-17 15:59:35 +02:00
committed by GitHub
parent d7f4ce6cff
commit fac9aac821
4 changed files with 30 additions and 11 deletions

View File

@@ -290,15 +290,22 @@ void osSpecificInit();
// This attaches to the parents process console, or creates a new one if it doesnt exist.
void attachOrCreateConsole();
#if HAVE_MALLOC_TRIM
/**
* Call this after freeing bigger blocks of memory. Used on some platforms to
* properly give memory back to the OS.
* @param amount Number of bytes freed
*/
#if HAVE_MALLOC_TRIM
void TrackFreedMemory(size_t amount);
/**
* Call this regularly from background threads. This performs the actual trimming
* and is potentially slow.
*/
void TriggerMemoryTrim();
#else
inline void TrackFreedMemory(size_t amount) { (void)amount; }
static inline void TrackFreedMemory(size_t amount) { (void)amount; }
static inline void TriggerMemoryTrim() { (void)0; }
#endif
#ifdef _WIN32