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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:39:29+00:00 2026-06-09T00:39:29+00:00

I have a simple class MyDataClass with a member (obj) that implements IDisposable: public

  • 0

I have a simple class MyDataClass with a member (obj) that implements IDisposable:

public class MyDataClass : IDisposable
{
    private DisposableObject obj;
    private List<string> list;
    private int c;

    public MyDataClass()
    {
        obj = new DisposableObject();
        list = new List<string>();
        c = 114;
    }

    public void Dispose()
    {
        obj.Dispose();
    }
}

public class DisposableObject : IDisposable
{
    public void Dispose()
    {
        // Free resource
        Console.WriteLine("Dispose DisposableObject");
    }
}

When I run the Code Analysis I get the CA1063 warning which shows me that I should call GC.SuppressFinalize() method in the Dispose() method in MyDataClass implementation.

And I am really confused about this CA1063 warning. Because as far as I know, I should call GC.SuppressFinalize() to indicate to the garbage collector:

“Hey GC, do not worry about this object because I have done already all cleaning work for you!”

So please confirm if I am wrong or not. If I will add the GC.SuppressFinalize() I will get rid of the CA1063 but it will cause that GC will not clean my object. So I will have a memory leak because other class members (managed code) will be not cleaned.

  • 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-06-09T00:39:31+00:00Added an answer on June 9, 2026 at 12:39 am

    If I will add the GC.SuppressFinalize() I will get rid of the CA1063
    but it will cause that GC will not clean my object.

    No, your objects will still be collected.

    “Hey GC, do not worry about this object because I have done already all cleaning work for you!”

    You’re actually only saying: don’t worry about the Finalizer (destructor) of this object. If it has one.

    And that is where Code Analysis is getting it wrong: your class does have an IDisposable.Dispose() method but it does not have a destructor. So the warning is pointless, being over protective and triggering on the wrong reason. Disable or ignore it.

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

Sidebar

Related Questions

I have this simple class: public class MappingCollection<T> : List<T> { private int _declaredTotal
I have an simple class that I get from a webservice. public class person
I have a simple class derived from a generic list of string as follows:
I have simple problem: class Weapon{ public: int dmg; float speed; int rate; };
I have a simple class: public class MyClass() { public string Property1 {get;set;} public
I have a simple class Name: class Name { private: char nameStr[30]; public: Name(const
I have a simple class like this: class A { public: void f(const int&
I have a simple class XmlFileHelper as follows: public class XmlFileHelper { #region Private
I have a simple class that contains a hashmap: @XmlRootElement() public class Customer {
I have a simple class class symbol_entry { private: static unsigned long uid; public:

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.