How to free komputer memory after dispose

R

Robert

I wrot program wich is included to the other program by using createobject()
function.
This object somtimes is showing a form with some information. After closing
a form and calling a Dispose() metod, the komputer does not free memory and
the object takes mor memory afret showing a form again. The main program can
not be shut down - industrial application.
Can any body help me with this. Please

Robert
 
D

Dan Bass

Robert,

Calling dispose on an object tells the .NET garbage collector that the item
is ready to be removed. It does not necessarily remove the object from
memory instantly.
You'll find the memory will drop off in a matter of seconds/maybe minutes,
if it is no longer referenced by another object.

One way you could speed up the process would be to call "GC.Collect()" after
the dispose call.

Hope that helps.
Dan.
 
I

Indie Pop

Ollie said:
check out this guys blog some very good advice about garbage collection

http://blogs.msdn.com/ricom/archive/2004/11/29/271829.aspx

I used to think that what he says:

" It's fair to say that most usages of GC.Collect() are a bad idea "

was right -- UNTIL I started working with a COM dll. There was no way to
completely rid myself of it (release resources) until I called it with
class I created that used a destructor that included GC.Collect and
finalizers.
 
O

Ollie Riches

I guess thats why it says 'most usages'......


Indie Pop said:
I used to think that what he says:

" It's fair to say that most usages of GC.Collect() are a bad idea "

was right -- UNTIL I started working with a COM dll. There was no way to
completely rid myself of it (release resources) until I called it with
class I created that used a destructor that included GC.Collect and
finalizers.
 
C

Chris Lyon [MSFT]

Dan,

Dispose does NOT tell the garbage collector that the item is ready to be removed. Dispose should free any unmanaged resources held by the object. The only way to tell the
GC that an object is ready to be collected, is to ensure there are no live references to that object.

See
http://weblogs.asp.net/clyon/archive/2004/09/21/232445.aspx
http://weblogs.asp.net/clyon/archive/2004/09/23/233464.aspx

for more information about Dispose.

-Chris

--------------------
Robert,

Calling dispose on an object tells the .NET garbage collector that the item
is ready to be removed. It does not necessarily remove the object from
memory instantly.
You'll find the memory will drop off in a matter of seconds/maybe minutes,
if it is no longer referenced by another object.

One way you could speed up the process would be to call "GC.Collect()" after
the dispose call.

Hope that helps.
Dan.


--

This posting is provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

Note: For the benefit of the community-at-large, all responses to this message are best directed to the newsgroup/thread from which they originated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top