C # gabbage Collecting System

Source: Internet
Author: User

* This program is very clever to detect the garbage collection mechanism, found the following conclusions:
* Garbage collection will only start when memory is critical Gc.collect ()
* From the running of this program, delete is continuously appearing, which shows the strength of garbage collection.
* New haha () This thing is really rubbish and will be recycled (unless it has a timer, this object is occupied by another thread)

Using system;using system.windows.forms;using system.threading;class haha{    int[] a=new int[10000000];    Haha ()    {        Console.WriteLine ("created");     }    void Run ()    {         Console.WriteLine ("I am Running");    }    ~haha ()    {        Console.WriteLine ("deleted");    }    static void Main () {for        (int i = 0; i <; i++)        {            new haha (). run ();            Gc. Collect ();        }        Application.Run ();    }}

C # gabbage Collecting System

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.