Memory Leaks

  • Thread starter Thread starter darkStar_e2
  • Start date Start date
D

darkStar_e2

Hi guys.
I have an applications which unfortunately eating up all the computer
resources. the this is that it is not releasing the resources (memory) that
it has eaten after it was closed...
how do i handle this...
 
Hi guys.
I have an applications which unfortunately eating up all the computer
resources. the this is that it is not releasing the resources (memory) that
it has eaten after it was closed...
how do i handle this...

Is that even possible under .Net?
 
Have you gotten to a low memory condition yet? If not, it may just be the
garbage collector has not seen the need to collect (highly possible). If so,
you may not be clearing Interop resources (files, database connections) and
disposing those that are applicable (if the object uses IDisposeable, call
Dispose() ... always).

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

*************************************************
Think outside the box!
*************************************************
 
True memory leaks are theoretically impossible. Most "memory leaks" are
simply the way .NET handles clean up. When the system needs memory for other
stuff or runs low, the GC collects. Otherwise, it simply lets the objects
sit out there. Seems like a bad system, in theory, but it works rather
nicely. Not cleaning up memory until needed and memory leaks are two
different things.

If you use certain objects and do not Dispose() so the GC can collect, you
can cause a "memory leak" of sorts, as the COM objects are never ref counted
down to zero, so they do not destroy. Not a real memory leak, per se, but
much more expensive than the GC not firing. There are CLR routines to
attempt to save you on this one, as well, but not as efficient as .NET
objects.

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

*************************************************
Think outside the box!
*************************************************
 
I am having this issue too.

I know that for some objects, however, you can use the Object.Dispose()
method when you are done with it, but I am not sure what else to do.

Christopher
 
Hi guys.
I have an applications which unfortunately eating up all the computer
resources. the this is that it is not releasing the resources
(memory) that it has eaten after it was closed...
how do i handle this...

Are you using large datasets? Datasets gobble memory like crazy.
 
Darkstar,
I have an applications which unfortunately eating up all the computer
resources. the this is that it is not releasing the resources (memory)
that
it has eaten after it was closed...
how do i handle this...

I can read your message in two ways.

1. Your program is closed and the memory is still not available
2. The resources are closed and after that the memory from the resources is
not released.

When it is the last, are you than sure it is not just an endless loop?

Cor
 
This is the real picture.. My program has multiple forms which in turn uses
larege datasets. when i opened the form which retrieves data from the
database and loads it to the dataset, it eats up a lot of the available
memory. On the closed and closing event of the form, i disposed all the
objects i used but what bothers me is that why is the eaten resources
(memory) does not return (released) to its previous availability. It only
does when i closed the entire program..
 
Darkstar,

There are a lot of things important with garbage collection some of them.

The garbage collector starts only to work when there is time or resources
needed. When that is still not happened it does nothing not spending time
with doing things which are not needed.

It collects only objects which have not any reference anymore. Not
themselves as an object however they should not be referenced themselves as
well.

This has nothing to do of going out of scope or by setting an object to
nothing, all the referencing object should have as well no reference
anymore.

By instance
Dim datagrid as new datagrid
dim new dt as new datatable
datasgrid.datasource = dt
dt = nothing

There is still a reference from your datagrid, so the dt is not collected.

I hope this helps?

Cor
 

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

Similar Threads


Back
Top