tags:

views:

56

answers:

1
+1  Q: 

SMTPClient.Send

Hi All,

I have a memory leak when calling SMTPClient.Send.

Please help to fix it.

+1  A: 

It is a very common mistake to assume that Taskmgr.exe is a leak detection tool. The combination of the .NET garbage collector and the Windows heap manager is far too sophisticated to be reverse-engineered from the numbers you see in that tool.

Proof it to yourself by sending thousands of email messages. If SmtpClient.Send() really leaks then your program will quickly crash with a OutOfMemory exception. Get more insight in the memory usage of a .NET program with Perfmon.exe and the performance counters in the .NET CLR Memory category. And a good book, like Richter's CLR via C#.

Hans Passant
Thanks for answer, but I checked the memory with other tools too, and the result is the same.
Wilson
We can't look over your shoulder. I don't think anybody can help you until you document what you found with those "other tools".
Hans Passant
I used performance counter, and get the same result
Wilson
Hmya, how did the "send a thousand emails" test work out?
Hans Passant
I am sending 1500 mails at once and my memory grow up like 30 Mb
Wilson
You've got about ~1800 MB to go before you have a real problem. Keep sending, try a million.
Hans Passant