Use malloc_trim

This commit is contained in:
DarthSim
2020-01-10 20:52:40 +06:00
parent 4f178cf325
commit c0fb6b1435
3 changed files with 30 additions and 2 deletions

20
free_memory_linux.go Normal file
View File

@@ -0,0 +1,20 @@
// +build linux
package main
/*
#include <features.h>
#ifdef __GLIBC__
#include <malloc.h>
#else
void malloc_trim(size_t pad){}
#endif
*/
import "C"
import "runtime/debug"
func freeMemory() {
debug.FreeOSMemory()
C.malloc_trim(0)
}