Hi Michel, Have tried collecting your program's heap profiles [1] (maybe once after each reload cycle)? Comparing pprof results should show you what objects leak memory.
[1]: https://blog.golang.org/profiling-go-programs On Tuesday, April 30, 2019 at 3:36:34 PM UTC+2, Michel Levieux wrote: > > Hi all, > > I'm currently having a lot of trouble debugging the memory usage of the > program I'm working on. This program, everyday at a given time, reloads a > bunch of data (that's been updated by another program) into its memory. The > following function: > > // PrintMemUsage outputs the current, total and OS memory being used. As > well as the number > // of garage collection cycles completed. > func PrintMemUsage() { > var m runtime.MemStats > runtime.ReadMemStats(&m) > // For info on each, see: https://golang.org/pkg/runtime/#MemStats > fmt.Printf("Alloc = %v MiB", bToMb(m.Alloc)) > fmt.Printf("TotalAlloc = %v MiB", bToMb(m.TotalAlloc)) > fmt.Printf("Sys = %v MiB", bToMb(m.Sys)) > fmt.Printf("NumGC = %v\n", m.NumGC) > } > > Outputs this: > > Alloc = 103861 MiB > TotalAlloc = 6634355 MiB > Sys = 232088 MiB > NumGC = 3822 > > The program reloads its data everyday but everyday the few references that > existed for the given data is overwritten by the new one. And indeed the > "Alloc" line above seems to stay around 100GB. Where I don't understand > what happens is that in the htop line of the program, the memory that is > used by the program keeps growing as the days pass, and when it reaches > close to 100% percent of the host's memory, the program will crash > eventually. > > Any idea that would help me debug this memory inconstency between memstats > and htop is welcome. I can also provide more information but no particular > piece of code directly from the project. > > Thank you all in advance. > > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.