How to handle memory allocation i shared hosting environments? (GC.Collect)

J

jdlwright

Hi, a customer is using our fairly memory intensive web app. in a
shared hosting environment
and the other day their host 'banned' (I think they just killed the
process) them for memory abuse.

Our app. has been profiled with SciTech's Mem Profiler, and it seems
that some of the issues relate to .NET bugs, but are alleviated by use
of System.GC.Collect(). I'm under the impression that it's generally
bad form to call this yourself, but at the same time, it strikes me
that the GC probably doesnt realise it's in a shared hosting
environment and there is happy to use up as much memory as it likes.
Possibly the host could do a better job of configuration(?), but that
doesnt really help much since we can't go around telling customers to
tell their hosts to sort out their config -> good way to lose a
customer.

So question is; what are the cons of calling Collect(), are they just
speed related?

Any tips would be welcome

Thanks
Jim
 
S

Steve C. Orr [MVP, MCSD]

I say go ahead and call GC.Collect sparingly. That's why it's there.
It does use significant CPU cycles so don't call it very often or it could
degrade performance.
 
B

bruce barker \(sqlwork.com\)

if GC.Collect() helps, then you probably are not calling Dispose() when you
are supposed to, so you are not releasing unmanged memory as early as
possible.

If you are using com interop, then you probably are not releaseing the com
objects with calls to ReleaseComObject, or are using double dot notion
(myobject.a.b) which will cause excessive use of memory (again the com
object is not dereferenced when done, so it hangs on to unmanaged memory)

-- bruce (sqlwork.com)
 

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

Members online

Forum statistics

Threads
473,744
Messages
2,569,481
Members
44,900
Latest member
Nell636132

Latest Threads

Top