Need to detect memory leak in my app

I have a memory leak in my app. I just see in task manager how RAM grows when app is running. In case this helps, this is my app: GitHub - idewave/idewave-cli at dev.

Could somebody help me to detect where is memory leak ? What are the common practices and approaches ?

You can use valgrind. It can be invoked as valgrind --tool memcheck --leak-check full <program>.


do you know alternative for Win10 ?

P.S. I do not use unsafe directive in my code.

Are you sure these are memory leaks? I didn't even find a single core::mem::forget in your code. Looks like you're building your app in debug mode

1 Like

I build app in release: cagro build --release. When I run it from .exe it crashes after some time, when I run it from console it not crashes. In both cases memory grows pretty fast.

Windows won't reclaim the allocated memory immediately.

1 Like

Does it mean used RAM will grow until full-filled ?

Yes and no. The OS will eventually reclaim memory that's been freed. When it needs to.

(But really, unused RAM is useless RAM.)

1 Like

Well, I will try to wait until all RAM is used.

In the meantime you can observe your program's behavior with a Windows debugger (such as the one coming with Visual Studio or gdb) and see if there is a leak or not. The task manager isn't made for that kind of tracing.

1 Like

Unfortunately, I have no way to test the application so I cannot gather any memory stats for you. But I was able to build it on Ubuntu with WSL2, meaning you should be able to use Valgrind memcheck on it.

Another option for leak checking is to use jemalloc as the global_allocator and use its suite of leak checking tools (which more or less resembles what Valgrind has): Use Case: Leak Checking · jemalloc/jemalloc Wiki (

A third option is dhat (which is based on Valgrind DHAT, which itself is sort of a more advanced version of Valgrind memcheck.) This one might even work on Windows natively, I haven't actually tried it there.

Good debugging tools are still sadly missing on Windows, but WSL does enable some good debugging facilities in some cases. I think it might fit your situation quite well.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.