I added ccall(:malloc_trim, Cvoid, (Cint,), 0)
after the GC.gc()
call and I’m calling the GC periodically, approximately few times per hour, and I was able to free some memory.
Not everything has been freed, but this is definitely much better than what I have observed previously, where I was not calling the malloc_trim
.
I suppose it’s somehow related to the glibc is optimized for memory allocations microbenchmarks · Issue #42566 · JuliaLang/julia (github.com) and the other parts might be actually some references, but it seems not all of the allocated memory was references in my code.
Also putting the GC.safepoint()
to all threads seemed to help a bit.