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 7507361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:28:24+00:00 2026-05-29T22:28:24+00:00

I am a little confused about memory clean up in an ASP.NET application. I

  • 0

I am a little confused about memory clean up in an ASP.NET application. I had defined several destructors–I know this isn’t the new .NET way of doing things, but I am a creature of habit and I always did it this way in c++– that were working wonderfully in just about every scenario. However, I have noticed that they are sometimes not called in my ASP.NET applications.

I am thinking about implementing IDisposable, but I am under the impression that IDisposable is for other users of your code, and I am not sure that ASP.NET would call Dispose when it is finished with the object. Could someone clarify on this?

What is the best, and by best I mean that it will always work– way to clean up my unmanaged memory?

Edit

This seems to indicate that if the class containing potential unmanaged memory is a member of an encapsulating class, then the destructor is the best strategy. This certainly makes sense to me since I could hardly put a try or a using around a class member. Even then however, that brings me back to my question, it sometimes never gets called in my ASP.NET app.

  • 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-29T22:28:25+00:00Added an answer on May 29, 2026 at 10:28 pm

    All classes which handle unmanaged resources should implement the IDisposable interface.

    For a little more info, there are two issues with the garbage collector. First, you have no idea when it’s going to run. Second, it has zero knowledge of unmanaged resources.. That’s why they are called unmanaged.

    Therefore it’s up to the calling code to properly dispose of objects that utilize unmanaged resources. The best way to do this is to implement the above interface and either wrap the object in a using ( ) { } statement or, at the least, a try .. finally. I generally prefer the using statement.

    Also, by implementing IDisposable you are signaling to other developers that this class deals with unmanaged resources so they can take the appropriate steps to ensure things are called correctly.

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

Sidebar

Related Questions

I'm a little confused about how ValueType objects are managed memory-wise in .NET. I
I'm little bit confused with one thing about memory stack. From what I know
I'm working on a memory pool implementation and I'm a little confused about pointers
I am a little confused about the roles of a java application server and
I'm a little confused about the HTTP protocol, from what i know HTTP was
I am little confused about vptr and representation of objects in the memory, and
I'm a little confused about clean-up order when you're using PThreads with regard to
So I'm a little confused about Qt's memory management. I was looking at the
I am a little confused about what the partial application of flip might do.
I a little confused about how this work even if it works properly. I

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.