PC Review


Reply
Thread Tools Rate Thread

ASP.NET Object Disposal

 
 
mukulprabhu@gmail.com
Guest
Posts: n/a
 
      20th Aug 2006
Hello there,

Is it compulsory that the component objects created in code behind
should be disposed explicitly.

For eg.

first.cs
index.aspx.cs
-----------------------------------------------------
-----------------------------------------------------
Class first first
objFirst = new first();
{
page_load()
method A () {some code} {
}
objFirst.A();
}

in the above example is it nessesary to dispose "objFirst" object.

Anticipating your reply.

Thanx in advance.

 
Reply With Quote
 
 
 
 
Sarat Pediredla
Guest
Posts: n/a
 
      20th Aug 2006
Mukul,

I never dispose my component objects explicitly. I wonder what gave you
the idea? I am assuming you are putting first.cs in App_Data (assuming
you are using .NET 2.0) but nevertheless the Garbage Collection should
handle this.

Sarat

(E-Mail Removed) wrote:
> Hello there,
>
> Is it compulsory that the component objects created in code behind
> should be disposed explicitly.
>
> For eg.
>
> first.cs
> index.aspx.cs
> -----------------------------------------------------
> -----------------------------------------------------
> Class first first
> objFirst = new first();
> {
> page_load()
> method A () {some code} {
> }
> objFirst.A();
> }
>
> in the above example is it nessesary to dispose "objFirst" object.
>
> Anticipating your reply.
>
> Thanx in advance.


 
Reply With Quote
 
=?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
Guest
Posts: n/a
 
      21st Aug 2006
Objects normailly do not need to be disposed unless they have resources or
referencess to other objects that have unmanaged resources that need to be
disposed (file handles, bitmaps, network streams, sockets, connections, etc.)

If your object has a Dispose method, you can call it, or have your class
implement the IDisposable pattern and it can call it.
Otherwise, objects are destroyed automatically by the runtime and in the
case of an ASP.NET page, everything goes away anyway as soon as the page
lifecycle is complete and the HTML has been sent out to the browser.

Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com




"(E-Mail Removed)" wrote:

> Hello there,
>
> Is it compulsory that the component objects created in code behind
> should be disposed explicitly.
>
> For eg.
>
> first.cs
> index.aspx.cs
> -----------------------------------------------------
> -----------------------------------------------------
> Class first first
> objFirst = new first();
> {
> page_load()
> method A () {some code} {
> }
> objFirst.A();
> }
>
> in the above example is it nessesary to dispose "objFirst" object.
>
> Anticipating your reply.
>
> Thanx in advance.
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
unsure about object disposal Steve Microsoft C# .NET 2 22nd Oct 2006 05:51 AM
Advice on best way to handle object disposal... =?Utf-8?B?Um9iZXJ0IFZhc3F1ZXo=?= Microsoft C# .NET 2 10th Jan 2006 11:11 PM
Com object Garbase disposal Matt MacDonald Microsoft Dot NET Framework 12 26th Sep 2005 08:24 PM
Correct Disposal of Pen Object Chris Microsoft VB .NET 4 18th Jul 2005 05:33 PM
class object disposal Philip Gray Microsoft Dot NET Compact Framework 1 16th Feb 2004 06:21 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:36 AM.