Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6167603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:32:32+00:00 2026-05-23T22:32:32+00:00

I wrote a small Server class which basically is a TcpListener wrapper and ThreadPool

  • 0

I wrote a small Server class which basically is a TcpListener wrapper and ThreadPool thread spawner.

The threads run Server::ProcessMessage() which does some work sending messages to and fro and then quits at the end of it.

But just before exiting the function, I also call TcpClient.GetStream().Close() and then TcpClient.Close(). I don’t use any Mutex or ManualResetEvent WaitHandles.

Tested the Client and Server, everything works except in task manager it shows the Mem Usage keep on increasing on every Server::ProcessMessage(). Even after all Client apps have been disconnected and closed, the Mem Usage is still there, not decreased.

Server is running as a windows service.

How do I know if it is a sign of memory leak or just garbage collector not doing its job (yet)?

Thanks.

EDIT:
I think I found the cause of my “memory leak”. I had Console.WriteLine() in my Server::ProcessMessage(). Still it would be helpful if there was an easier way to check for memory problems.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T22:32:33+00:00Added an answer on May 23, 2026 at 10:32 pm

    Try using WinDbg with SoS extension to check if unneeded objects are still referenced in the heap. Check this link also.

    You usually start by using !DumpHeap -type (some-type-or-just-namespace) to get a list of objects of a certain type (I usually just write the relevant layer’s namespace to get a list or objects which I believe might be still in memory).

    If you have more than one instance of a certain object, you will need to pick one address which corresponds to the MT for your object, and then call !gcroot (your-address) to see what’s keeping your object alive.

    In most cases, objects are kept alive because one of their methods is registered as an event handler for some other object’s event. A good practice is to always detach your event handlers from parent classes once your object is no longer needed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote small FTP Client Applet which uploads files to FTP Server using Commons
I wrote a small program, kind of specialized HTTP server in haskell, which is
We wrote a small Windows class library that implements extension methods for some standard
I wrote a small program to test accessing a widget parent's slot. Basically, it
I recently wrote a small AJAX-based chat program. The clients ping the server occasionally
I'm facing a weird issue. I wrote a small server in C++ that stores
I wrote a very small application, which access the Remote Power Shell of Exchanger
I'm looking to write a small proxy server for kicks and giggles. Apart from
I wrote a small PHP application several months ago that uses the WordPress XMLRPC
I wrote a small PHP application that I'd like to distribute. I'm looking for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.