Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
|
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 21st, 2007, 09:22 AM
Authorized User
 
Join Date: Jun 2007
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

http://www.andymcm.com/dotnetfaq.htm#5.9

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();
        ob1.Use();
    }
}

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

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

    internal static void staticUse(int arr)
    {
        GC.Collect();
        ++arr;
    }

    ~clsTempObject()
    {
        finalizerFlag = true;
        arr = 99;
    }
}

- Vishu
__________________
- Vishu
 
Old June 22nd, 2007, 05:51 AM
Authorized User
 
Join Date: Jun 2007
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to vishwjeet
Default

Hey..I posted same query in beginners section too..but didnt got any solution.


- Vishu





Similar Threads
Thread Thread Starter Forum Replies Last Post
work of garbage collector in .net Anuradha ASP.NET 2.0 Basics 0 October 3rd, 2008 12:33 AM
Garbage Collection azizur123 .NET Framework 2.0 1 February 3rd, 2008 11:16 AM
garbage collection generalization tapan General .NET 2 April 27th, 2007 07:13 AM
Garbage Collection... kk_katepally General .NET 1 December 21st, 2004 04:18 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.