Memory increase and hang

  • Thread starter Thread starter Dan Pavel
  • Start date Start date
D

Dan Pavel

Hi,

I have an C# application and after about 12 hours it hangs with a .NET
Error System.OutOfMemoryException. This error is received after
GC.GetTotalMemory: 100038436 and in task manager the used memory is
about 130,000k.
I used GC.Collect but did not help. Please help.

Thanks in advance
Dan
 
I have an C# application and after about 12 hours it hangs with a .NET
Error System.OutOfMemoryException. This error is received after
GC.GetTotalMemory: 100038436 and in task manager the used memory is
about 130,000k.
I used GC.Collect but did not help. Please help.

Almost certainly you are not disposing resources correctly - you ABSOLUTELY
CANNOT rely on the GC to do this for you!!!!
 
You must make sure you understand the GC and how it works... I strongly advise
you to have a loot at a few articles:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/dotnetgcbasics.asp
http://msdn.microsoft.com/library/default.asp?url=/msdnmag/issues/1100/GCI/TOC.ASP
http://msdn.microsoft.com/library/default.asp?url=/msdnmag/issues/1200/GCI2/TOC.ASP
http://blogs.msdn.com/ricom/archive/2005/05/23/421205.aspx

Without looking at the code i would say that you are not disposing of resources
or you are caching too much data without releasing it.... but it could be
so much more... A very common mistake is that many programmers work against
the GC without knowing it... read those articles and reformulate you question
as well as posting some code you suspect is holding data or allocating unecessary
data.
And about calling GC.Collect, please read http://blogs.msdn.com/ricom/archive/2004/11/29/271829.aspx.



Erick Sgarbi
 
That means you are consuming more memory than there is available. The reason
can be a bug in your code, or simply a design error.
A bug can be not disposing unmanaged resources, but there might be other
reasons.
A design error can be allocating too large data structures (arrays,
ArrayLists ...).

Anyway, what you should do is measure the memory consumption at run-time
using permon.exe, pay special attention to GC memory and non-GC memory, that
are the CLR memory counters and the process private byte counters.

Willy.
 
Hi,

Probably you have one of two situations:
1- You are keeping too many objects in memory without dereferencing them
hence they are never collected
2- you use any external resource that you are nt disposing.

what your app does?


cheers,
 
My app is monitoring some workstations and start/stop some workflows on
that machines. I am using SNMP for this.

An interesting thing: my app runs hidden. I have a notification Icon in
task bar. when I click on the icon the form opens. after I close the
form (app keeps running) the used memory reported for my app's process
in Task manages goes to about 1,000 k. Why this way the memory goes down
and else goes up ?

Thanks,
Dan
 
Back
Top