PC Review


Reply
Thread Tools Rate Thread

Disposing objects

 
 
=?Utf-8?B?Sk1BcnJveWF2ZQ==?=
Guest
Posts: n/a
 
      22nd Jul 2004
Hi, im have a trouble with the memory, my app is to big and it consumes a LOT of memory, i read the posts of dispose in the forum, and all recomends to leave the GC do this work for managed resources, should i dispose the datasets and other graphic objects in my app?

Thanks a lot
 
Reply With Quote
 
 
 
 
Sunny
Guest
Posts: n/a
 
      22nd Jul 2004
If some class implements IDisposable, or has Dispose() or Close(), most
probably this class holds some unmanaged resources and it is recommended
to call Dispose or Close once you are done with it. But I see no reason
to use Dataset.Clear().

Sunny

In article <2CE051DC-6B16-4690-B4A5-(E-Mail Removed)>,
(E-Mail Removed) says...
> Hi, im have a trouble with the memory, my app is to big and it consumes a LOT of memory, i read the posts of dispose in the forum, and all recomends to leave the GC do this work for managed resources, should i dispose the datasets and other graphic objects in my app?
>
> Thanks a lot
>

 
Reply With Quote
 
=?Utf-8?B?Sk1BcnJveWF2ZQ==?=
Guest
Posts: n/a
 
      22nd Jul 2004
Hi Sunny, and what about the dataset.dispose

"Sunny" wrote:

> If some class implements IDisposable, or has Dispose() or Close(), most
> probably this class holds some unmanaged resources and it is recommended
> to call Dispose or Close once you are done with it. But I see no reason
> to use Dataset.Clear().
>
> Sunny
>
> In article <2CE051DC-6B16-4690-B4A5-(E-Mail Removed)>,
> (E-Mail Removed) says...
> > Hi, im have a trouble with the memory, my app is to big and it consumes a LOT of memory, i read the posts of dispose in the forum, and all recomends to leave the GC do this work for managed resources, should i dispose the datasets and other graphic objects in my app?
> >
> > Thanks a lot
> >

>

 
Reply With Quote
 
Cowboy \(Gregory A. Beamer\) [MVP]
Guest
Posts: n/a
 
      22nd Jul 2004
Using Dispose() is a good practice, as it marks the objects for GC. It will
not automagically clear up memory, but it will help with cleaning up objects
when the GC fires. If you see a Dispose() method (ala the Connection
objects), use it.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************
Think Outside the Box!
************************************************
"JMArroyave" <(E-Mail Removed)> wrote in message
news:2CE051DC-6B16-4690-B4A5-(E-Mail Removed)...
> Hi, im have a trouble with the memory, my app is to big and it consumes a

LOT of memory, i read the posts of dispose in the forum, and all recomends
to leave the GC do this work for managed resources, should i dispose the
datasets and other graphic objects in my app?
>
> Thanks a lot



 
Reply With Quote
 
AlexS
Guest
Posts: n/a
 
      22nd Jul 2004
Hi,

you'll be better off if you dispose everything what is IDisposable. And even
much better if you profile app for allocations, for example with
CLRProfiler, which you can get free from MS site.

You might have issues with memory even with code like this:

using (Brush b = new SolidBrush(Color.Black)) {
...some painting
}

If you call this is in loop or you have too many paints you will finish with
thousands of brushes in heap just because GC is not able to collect all
freed ones.

You might want to check also
http://msdn.microsoft.com/architectu...l/scalenet.asp
for additional details on how to deal with GC. But profiler is your best bet
to find what is eating memory and why,

HTH
Alex

"JMArroyave" <(E-Mail Removed)> wrote in message
news:B57BEBD2-B165-44C7-B1EA-(E-Mail Removed)...
> Hi Sunny, and what about the dataset.dispose
>
> "Sunny" wrote:
>
> > If some class implements IDisposable, or has Dispose() or Close(), most
> > probably this class holds some unmanaged resources and it is recommended
> > to call Dispose or Close once you are done with it. But I see no reason
> > to use Dataset.Clear().
> >
> > Sunny
> >
> > In article <2CE051DC-6B16-4690-B4A5-(E-Mail Removed)>,
> > (E-Mail Removed) says...
> > > Hi, im have a trouble with the memory, my app is to big and it

consumes a LOT of memory, i read the posts of dispose in the forum, and all
recomends to leave the GC do this work for managed resources, should i
dispose the datasets and other graphic objects in my app?
> > >
> > > Thanks a lot
> > >

> >



 
Reply With Quote
 
Sunny
Guest
Posts: n/a
 
      22nd Jul 2004
Hi,

I do not know the internals of Dataset, so I can not tell you if it uses
some unmanaged resources. But in general, you use IDisposable pattern
when your class holds some unmanaged resources and you want to allow the
user to release them in timely manner.

In most cases, if IDisposable is implemented, it should be called (at
least with the buildin framework classes).

Sunny

In article <B57BEBD2-B165-44C7-B1EA-(E-Mail Removed)>,
(E-Mail Removed) says...
> Hi Sunny, and what about the dataset.dispose
>
> "Sunny" wrote:
>
> > If some class implements IDisposable, or has Dispose() or Close(), most
> > probably this class holds some unmanaged resources and it is recommended
> > to call Dispose or Close once you are done with it. But I see no reason
> > to use Dataset.Clear().
> >
> > Sunny
> >
> > In article <2CE051DC-6B16-4690-B4A5-(E-Mail Removed)>,
> > (E-Mail Removed) says...
> > > Hi, im have a trouble with the memory, my app is to big and it consumes a LOT of memory, i read the posts of dispose in the forum, and all recomends to leave the GC do this work for managed resources, should i dispose the datasets and other graphic objects in my app?
> > >
> > > Thanks a lot
> > >

> >

>

 
Reply With Quote
 
AlexS
Guest
Posts: n/a
 
      23rd Jul 2004
DataSet has Dispose method. If object is IDisposable you must Dispose it
after use.

HTH
Alex

"Sunny" <(E-Mail Removed)> wrote in message
news:OqQ4$(E-Mail Removed)...
> Hi,
>
> I do not know the internals of Dataset, so I can not tell you if it uses
> some unmanaged resources. But in general, you use IDisposable pattern
> when your class holds some unmanaged resources and you want to allow the
> user to release them in timely manner.
>
> In most cases, if IDisposable is implemented, it should be called (at
> least with the buildin framework classes).
>
> Sunny
>
> In article <B57BEBD2-B165-44C7-B1EA-(E-Mail Removed)>,
> (E-Mail Removed) says...
> > Hi Sunny, and what about the dataset.dispose
> >
> > "Sunny" wrote:
> >
> > > If some class implements IDisposable, or has Dispose() or Close(),

most
> > > probably this class holds some unmanaged resources and it is

recommended
> > > to call Dispose or Close once you are done with it. But I see no

reason
> > > to use Dataset.Clear().
> > >
> > > Sunny
> > >
> > > In article <2CE051DC-6B16-4690-B4A5-(E-Mail Removed)>,
> > > (E-Mail Removed) says...
> > > > Hi, im have a trouble with the memory, my app is to big and it

consumes a LOT of memory, i read the posts of dispose in the forum, and all
recomends to leave the GC do this work for managed resources, should i
dispose the datasets and other graphic objects in my app?
> > > >
> > > > Thanks a lot
> > > >
> > >

> >



 
Reply With Quote
 
Sunny
Guest
Posts: n/a
 
      23rd Jul 2004
Did I say something else?


In article <(E-Mail Removed)>,
(E-Mail Removed) says...
> DataSet has Dispose method. If object is IDisposable you must Dispose it
> after use.
>
> HTH
> Alex
>
> "Sunny" <(E-Mail Removed)> wrote in message
> news:OqQ4$(E-Mail Removed)...
> > Hi,
> >
> > I do not know the internals of Dataset, so I can not tell you if it uses
> > some unmanaged resources. But in general, you use IDisposable pattern
> > when your class holds some unmanaged resources and you want to allow the
> > user to release them in timely manner.
> >
> > In most cases, if IDisposable is implemented, it should be called (at
> > least with the buildin framework classes).
> >
> > Sunny
> >
> > In article <B57BEBD2-B165-44C7-B1EA-(E-Mail Removed)>,
> > (E-Mail Removed) says...
> > > Hi Sunny, and what about the dataset.dispose
> > >
> > > "Sunny" wrote:
> > >
> > > > If some class implements IDisposable, or has Dispose() or Close(),

> most
> > > > probably this class holds some unmanaged resources and it is

> recommended
> > > > to call Dispose or Close once you are done with it. But I see no

> reason
> > > > to use Dataset.Clear().
> > > >
> > > > Sunny
> > > >
> > > > In article <2CE051DC-6B16-4690-B4A5-(E-Mail Removed)>,
> > > > (E-Mail Removed) says...
> > > > > Hi, im have a trouble with the memory, my app is to big and it

> consumes a LOT of memory, i read the posts of dispose in the forum, and all
> recomends to leave the GC do this work for managed resources, should i
> dispose the datasets and other graphic objects in my app?
> > > > >
> > > > > Thanks a lot
> > > > >
> > > >
> > >

>
>
>

 
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
Re: Disposing Objects? Adam Right Microsoft C# .NET 4 18th Oct 2006 05:37 PM
Disposing Objects Ken Getz Microsoft Dot NET Framework Forms 4 12th Oct 2005 05:11 AM
Disposing of Objects =?Utf-8?B?c3R1YXJ0X25pY29sbA==?= Microsoft Dot NET Compact Framework 0 18th Jul 2005 10:29 PM
Disposing of Objects -AGAIN =?Utf-8?B?RGVubmlz?= Microsoft VB .NET 10 28th Dec 2004 09:35 PM
disposing of objects James Brett Microsoft VB .NET 2 10th Mar 2004 01:21 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:57 PM.