Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. TcpClient create a memory leak ?!?

TcpClient create a memory leak ?!?

Scheduled Pinned Locked Moved .NET (Core and Framework)
performancehelpquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Alon Ronen
    wrote on last edited by
    #1

    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

    F 1 Reply Last reply
    0
    • A Alon Ronen

      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

      F Offline
      F Offline
      Fade Amit BS
      wrote on last edited by
      #2

      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)

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups