Memory leak in C#

R

Raja Gregory

Hi All,



I have developed a server application in C#. While running this
application, it is not running more than 30 minutes due to memory leak.
Could you tell me what will be the problem?



Thanks & Regards,

Raja.GS
 
J

Jon Skeet [C# MVP]

Raja said:
I have developed a server application in C#. While running this
application, it is not running more than 30 minutes due to memory leak.
Could you tell me what will be the problem?

Chances are you're holding on to a reference somewhere that you
shouldn't be. Without seeing any code or having any other information,
it's impossible to say more than that, really.

Jon
 
R

Raja Gregory

Thanks for the immediate reply. This is a big telecom application. I am
using lot of Hashtables and ArrayList in this project. How can I figure out
which is causing this problem? Is it any tool is there?

Thanks,
Raja.GS
 
S

Simon Hart

Likely to be when calling unmanged code, but diff to say without seeing some
code.
 
W

Wiktor Zychla [C# MVP]

Chances are you're holding on to a reference somewhere that you
shouldn't be. Without seeing any code or having any other information,
it's impossible to say more than that, really.

Jon

Jon - while developing several big applications (managed-code only!) I have
seen very rare and nondeterministic [Out of memory] exceptions. I belive
then that the garbage collector could somehow be mistaken in those few
situations (does anyone have a formal proof of gc correctness? I do not
think so and even if the proof exists it only proves that the algorithm is
correct and not the actual implementation). However, since I've never been
able to reproduce these problems, I've never paid much attention to them.

Raja - do you monitor the memory consumption of your application? Does the
memory consumption increases constantly by small fractions and then the
crash happens? Or maybe the memory stays at some fixed rate but then there
is a sudden allocation of big block of memory that causes the crash? Also,
as Simon suggested, are you using unmanaged resources?

Wiktor Zychla
 
R

Raja Gregory

Wiktor:



Yes the memory consumption increases constantly by small fractions and then
the
crash is happening. Basically my module is processing lot of events. Crash
is depending on no of events it is processing. Those events are trigged by
external another managed code module.



For example:- Agent Signed In event.

If no. of agents signed in is high, it will crash immediately.



Thanks,

Raja.GS



Wiktor Zychla said:
Chances are you're holding on to a reference somewhere that you
shouldn't be. Without seeing any code or having any other information,
it's impossible to say more than that, really.

Jon

Jon - while developing several big applications (managed-code only!) I have
seen very rare and nondeterministic [Out of memory] exceptions. I belive
then that the garbage collector could somehow be mistaken in those few
situations (does anyone have a formal proof of gc correctness? I do not
think so and even if the proof exists it only proves that the algorithm is
correct and not the actual implementation). However, since I've never been
able to reproduce these problems, I've never paid much attention to them.

Raja - do you monitor the memory consumption of your application? Does the
memory consumption increases constantly by small fractions and then the
crash happens? Or maybe the memory stays at some fixed rate but then there
is a sudden allocation of big block of memory that causes the crash? Also,
as Simon suggested, are you using unmanaged resources?

Wiktor Zychla
 
A

Andy

Raja,

Even if you're not doing any com interop, some classes in the framework
do. Check all classes which you use, and see if the class implements a
Dispose method. If it does you'll need to call Dispose before you
release the reference to that object.
 
W

Willy Denoyette [MVP]

Please stop guessing, start measuring. There are a number of good memory
profilers around for .NET.
First there is the 'ClrProfiler' freely downloadable from
http://www.microsoft.com/downloads/...1C-3870-43BE-8926-862B40AA0CD0&displaylang=en
another decent one is the scitech profiler, a preview is available from
http://www.scitech.se/.

Willy.


| Wiktor:
|
|
|
| Yes the memory consumption increases constantly by small fractions and
then
| the
| crash is happening. Basically my module is processing lot of events. Crash
| is depending on no of events it is processing. Those events are trigged by
| external another managed code module.
|
|
|
| For example:- Agent Signed In event.
|
| If no. of agents signed in is high, it will crash immediately.
|
|
|
| Thanks,
|
| Raja.GS
|
|
|
| message | > > Chances are you're holding on to a reference somewhere that you
| > > shouldn't be. Without seeing any code or having any other information,
| > > it's impossible to say more than that, really.
| > >
| > > Jon
| > >
| >
| > Jon - while developing several big applications (managed-code only!) I
| have
| > seen very rare and nondeterministic [Out of memory] exceptions. I belive
| > then that the garbage collector could somehow be mistaken in those few
| > situations (does anyone have a formal proof of gc correctness? I do not
| > think so and even if the proof exists it only proves that the algorithm
is
| > correct and not the actual implementation). However, since I've never
been
| > able to reproduce these problems, I've never paid much attention to
them.
| >
| > Raja - do you monitor the memory consumption of your application? Does
the
| > memory consumption increases constantly by small fractions and then the
| > crash happens? Or maybe the memory stays at some fixed rate but then
there
| > is a sudden allocation of big block of memory that causes the crash?
Also,
| > as Simon suggested, are you using unmanaged resources?
| >
| > Wiktor Zychla
| >
|
|
 

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

Memory Leak 23
Memory leak using pInvoke 3
Memory leak detection 1
Memory leak 1
Any memory leak in this code snippet? 3
Memory Leak with WMI 4
Memory leak 6
Memory leak when using COM library 3

Top