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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:59:13+00:00 2026-06-17T20:59:13+00:00

Possible Duplicate: .NET garbage collection not working properly here? I’ve tested the following code.

  • 0

Possible Duplicate:
.NET garbage collection not working properly here?

I’ve tested the following code.
when the button is clicked, objects are created and add them to the list. When another a button is clicked, the list is cleared

GC is destroying the objects, but memory usage does not decrease.
Why? Is there something wrong?

public partial class MainWindow : Window
{
    public List<MyModel> MyList;
    public MainWindow()
    {
        MyList = new List<MyModel>();
        InitializeComponent();
    }

    private void button1_Click_1(object sender, RoutedEventArgs e)
    {
        MyList = new List<MyModel>();
        for (int i = 0; i < 1000000; i++)
        {
            MyList.Add(new MyModel { ID = i, Description = "Model Id : " + i.ToString() });
        }
        MessageBox.Show("Complate!");
    }

    private void button1_Click_2(object sender, RoutedEventArgs e)
    {
        MyList.Clear();
        MyList = null;
    }
}

public class MyModel
{
    ~MyModel()
    {
        Console.WriteLine(Description);
    }
    public int ID { get; set; }
    public string Description { get; set; }
}
  • 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-17T20:59:14+00:00Added an answer on June 17, 2026 at 8:59 pm

    Suppose you own a warehouse. You store boxes in the warehouse. Some of the boxes are garbage, so periodically you throw them out. The square footage of the warehouse does not get smaller.

    If what you’re measuring is the total number of memory pages committed to the process, then you’re not measuring the number of boxes in the warehouse, you’re measuring the square footage of the warehouse.

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

Sidebar

Related Questions

Possible Duplicate: Can I run a .NET garbage collection from WinDbg? I'm debugging a
Possible Duplicate: Protect .NET code from reverse engineering? we just develop a application with
Possible Duplicate: ASP.NET MVC: No parameterless constructor defined for this object I'm working on
Possible Duplicate: .NET progressbar not updating I built a progress bar class that shows
Possible Duplicate: .NET Controls: Why aren’t all calls thread-safe? This question is not about
Possible Duplicate: Why does .Net Framework not use unsigned data types? In The C#
Possible Duplicate: ASP.NET authentication login and logout with browser back button I want to
Possible Duplicate: .NET How to check if path is a file and not a
Possible Duplicate: javax.net.ssl.SSLException: Not trusted server certificate I am trying to connect to server
Possible Duplicate: Why does .NET use banker's rounding as default? Here is a sample

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.