Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 21st, 2007, 09:22 AM
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

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
  #2 (permalink)  
Old June 22nd, 2007, 05:51 AM
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

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


- Vishu
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 06:35 AM.


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