mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-02 16:38:41 +00:00
Move malloc_trim invocations to background thread (#14744)
This commit is contained in:
parent
d7f4ce6cff
commit
fac9aac821
4 changed files with 30 additions and 11 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue