What is the best way to test for memory leaks in your program?
Printable View
What is the best way to test for memory leaks in your program?
If you don't want memory leaks, then do use any of the .Net languages. They don't suffer from memory leaks due to the memory management (Garbage Collector).
And you can't test for memory leaks by definition anyway, that would imply that you know where the wild pointers are pointing, hence no leak. :)
Memory leaks can still be caused by .Net. The garabe collector will free any memory from unused objects. However that is a poor programming practice to just let objects fly around with no reguard to properly disposing them. Surely there must be some utility out there that can give you some information on a possible leak in your code.
you could certainly look at the memory usage for the app in the task manager. If indeed you have stray objects not being relinquished, then in time your app should consume more and more memory. Another app that gives lots of memory usage is the process viewer that shipped with Visual Studio 6.0 tool set.Quote:
Originally Posted by Porsche944
kevin
Strictly speaking, letting objects lying around unused isn't a memory leak, just sloppy programming. Like wossname has indicated, memory leaks are not possible in .Net - however that doesn't mean that the garbage collector acts in ways that make sense (well, common sense anyway :bigyello: ).
There are several utilities that you can use to profile .Net apps (out of the top of my head I would recommend CLR Profiler). Also, take a look at the performance monitor, there are a bunch of .Net counters that involve memory metrics.