View Single Post
  #1 (permalink)  
Old June 21st, 2007, 09:22 AM
vishwjeet vishwjeet is offline
Authorized User
Join Date: Jun 2007
Location: Delhi, New Delhi, India.
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to vishwjeet
Default Garbage Collector -- Is it working?

Hey ppl, I am trying the following code to see what is the effect of GC.Collect on the code. As per

if GC.Collect is called, finalizer should be called for the object ob1. If GC.COllect is commented ...its unpredictable.

But for me this doesnt seems to be working. Any ideas?

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class GarbageCollectionDemo : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)
        clsTempObject ob1 = new clsTempObject();

internal class clsTempObject
    //int[] arr = new int[1];
    int arr;
    bool finalizerFlag;

    internal void Use()
        arr = 10;
        finalizerFlag = false;
        //arr[0] = 10;

    internal static void staticUse(int arr)

        finalizerFlag = true;
        arr = 99;

- Vishu
- Vishu