Wednesday, March 22, 2023
HomeGolangQuery: Detecting reminiscence leak by monitoring ReadMemStats - Getting Assist

Query: Detecting reminiscence leak by monitoring ReadMemStats – Getting Assist

Hi there fellow gophers!

I’ve a query concerning detecting reminiscence leaks. There’s an concept of detecting potential reminiscence leak by monitoring reminiscence. I’ve carried out a demo that runs a program and in a separate goroutine information runtime.MemStats. At the moment, I simply take a look at HeapAlloc each file after which attempt to search out the sample when there’s a simulated reminiscence leak. The simulated reminiscence leak that I selected is to open 100000 instances one file in a loop however go away it open. It accumulates 1MB roughly from storing file handlers.

I assumed that HeapAlloc or HeapInuse or StackInuse would enhance because the simulated reminiscence leak accumulates extra reminiscence. However it’s not the case, sadly.

Thanks for you consideration!

Hello, @Highzest, and welcome to the discussion board!

I’m unclear on what you’re query truly is; are you asking why HeapAlloc or HeapInuse or StackInuse didn’t present what you need? Or what you must use as a substitute? Each?

Sure, each. I have no idea the rationale these reminiscence stats don’t trace a possible existence of the reminiscence leak. And the way can use MemStats to indicate a possible reminiscence leak?



Please enter your comment!
Please enter your name here

Most Popular

Recent Comments