Sorry for the late reply. The problem was solved, thanks to everyone for the help.
Just to give a little more context. The lib that I'm using is MuPDF and I thought that I had a memory leak but in the end, it was just glibc not releasing the memory fast enough to the OS. I solved the problem by changing the allocator at MuPDF to jemalloc. At my first analysis, I did not know where was the problem because the code looked correct, as it was, but I started to think that maybe I was leaking the memory in C from the Go code calling things like C.CString. Then I thought how can I allocate in C from Go utility functions like C.CString using an allocator that has leak detection called memento that the MuPDF team built? Well, I still don't know. I did it once using unsafe, but not by using the actual C.CString call. And regards LD_PRELOAD I did not found a way of making everything work together, I don't have much experience with C.