kseen
kseen

Reputation: 397

Heap memory problems

There's a WCF self hosted service that must work 99% of time. Sometimes we got some memory troubles like this:

memory leaks

But service is working as usual after that issues. How can we manage this? Any tips and points to make robust services that will survive in different except situations are very very welcome.

Upvotes: 7

Views: 652

Answers (4)

Esteban Araya
Esteban Araya

Reputation: 29664

Are you 100% none of you dependencies have unmanaged code? I've seen something very similar to this happen, and it was happening because we were deallocating memory that another process would also try to deallocate later.

Upvotes: 0

Wegged
Wegged

Reputation: 2423

What are your Service Behaviors particularly ConcurrencyMode and InstanceContextMode.

if you have Multiple as ConcurrencyMode and InstanceContext set to (PerCall, or PerSession(default)) you can definetely run into issues if you have large DataStructures or undisposed resources.

if you are using multiple Concurrency try InstanceContextMode Single [ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple, InstanceContextMode = InstanceContextMode.Single)]

Upvotes: 0

Simon Mourier
Simon Mourier

Reputation: 139226

If it's a WCF problem (I'm not sure what to do with your dump), I suggest you activate WCF server-side tracing, and have a look at the exceptions if there are any (and edit your question so we can further help you).

Here is a link that explain how to do this:

How to enable WCF tracing

Upvotes: 0

CharithJ
CharithJ

Reputation: 47570

I am not too sure where the problem resides but memory leaking can be a reason.

All code is managed. And we use dotConnect for Oracle from devArt as data layer library.

You assume all code is managed, but there can be unmanaged parts. However, you must call the Dispose method for all the disposable objects after using them, don't think they are properly dispose once they go out of scope. The best practice is, not to let Disposable objects to go out of scope without calling their Dispose method. You may be able to use 'using' statements if you are using them as local variables.

DbConnection is a good example for disposable objects, make sure you dispose all the connections (disposable objects).

Upvotes: 3

Related Questions