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

  • Home
  • SEARCH
  • 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 5846875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:38:19+00:00 2026-05-22T12:38:19+00:00

I have a .NET System.Threading.Timer timer that ticks every 60 seconds and introduces a

  • 0

I have a .NET System.Threading.Timer timer that ticks every 60 seconds and introduces a memory leak on each tick.

On each tick of the timer, the code allocates an IDisposable object (called SocketsMessageConnector)…but I do dispose it correctly.

I ran .NET Memory Profiler and every 60 seconds I see a new instance of my SocketsMessageConnector class lingering in memory (so after 15 minutes, I have 15 instances). The memory profiler verifies that the instance is in fact disposed, but it shows the instance rooted by a TimerCallback, which is rooted by a _TimerCallback, which is rooted by a GCHandle…

What’s up here? Why is the TimerCallback holding on to the new instance created on every timer tick?

PS. The profiler forces 2 GCs before taking a snapshot, so I know it IS in fact a leak and not just an optimization by the GC.

  • 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-22T12:38:20+00:00Added an answer on May 22, 2026 at 12:38 pm

    Just because it’s been disposed, doesn’t mean that it’s been Garbage Collected yet.

    Try changing your timer to run twice a second, and then let it run for 10 minutes. Now check how many of your class objects are still “lingering in memory”. If you truely have a memory leak, you’ll have 1200 objects. But if Garbage Collection has jumped in, you’ll have considerably less – perhaps under 100.

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

Sidebar

Related Questions

I have an App that will send authenticated emails using System.Net.Mail and System.Net.NetworkCredential my
At my current job we have a CMS system that is .NET/SQL Server based.
I have a master page that contains an ASP.NET server side Menu control (System.Web.UI.WebControls.Menu)
In .NET I have already tried the configuration below successfully: <system.net> <connectionManagement> <add address=*
Currently I have: <system.net> <mailSettings> <smtp from=me@mydomain.com> <network host=localhost port=25 /> </smtp> </mailSettings> </system.net>
I have a large .NET web application. The system has projects for different intentions
Have you used VS.NET Architect Edition's Application and System diagrams to start designing a
I have developed a build system on MSBuild (NET 3.0) and cc.net to perform
I have a simple ASP.NET 3.5 SP1 Web Forms app... I've added the System.Web.Routing
The system I work on here was written before .net 2.0 and didn't have

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.