Memory increase and hang

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
 
M

Mark Rae

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!!!!
 
E

erick

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
 
W

Willy Denoyette [MVP]

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.
 
I

Ignacio Machin \( .NET/ C# MVP \)

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,
 
D

Dan Pavel

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
 

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