TcpClient create a memory leak ?!?
-
hi, i'm building a pop3 mail checker for my own use and i've noticed that each time my app check the mail - the memory usage in the task manger grow in few KB and doesnt come back. now i checked lots of mail checkers found on this site and others, all behave alike. when i've isolated my code parts, ive noticed it's the creation of the NEW TcpClient who causes the memory leak. i thought the garbage collector supposed to take care the old TcpClient but apparantley there's some problem. i also tried to use my own dispose methode for the tcpclient with GC.SuppressFinalize, none helped. now this is a serious problem as the mail checker supposed to run at all times (i usually boot my computer once a week or two...) any solutions ??? 10X, Alon
-
hi, i'm building a pop3 mail checker for my own use and i've noticed that each time my app check the mail - the memory usage in the task manger grow in few KB and doesnt come back. now i checked lots of mail checkers found on this site and others, all behave alike. when i've isolated my code parts, ive noticed it's the creation of the NEW TcpClient who causes the memory leak. i thought the garbage collector supposed to take care the old TcpClient but apparantley there's some problem. i also tried to use my own dispose methode for the tcpclient with GC.SuppressFinalize, none helped. now this is a serious problem as the mail checker supposed to run at all times (i usually boot my computer once a week or two...) any solutions ??? 10X, Alon
i wouldn't jump the gun and say there is a memory leak a good thing to know about the grabade collector in .net is that it collects garbage when it wants to :) an easy way to see this for yourself is to sequencially create and destroy let's say 100,000 objects. open the task manager to watch the memory status as the code runs for whatever time it takes him (i would even put it in a never ending loop just for the sake of the example) the loop should be something like { CreateObject(); DestroyObject(); } you will notice how the memory starts to fill up, and then just when you think the system is about to die, you'll see how in a second it all comes back to normal - that's the garbage collector waking up and doing it's job :) Let me know if it is a leak or just the garbage collector so i'll know whether to use the tcpClient. Fade (Amit BS)