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

Discussion in 'ASP .Net' started by jdlwright, Jun 12, 2006.

  1. jdlwright

    jdlwright Guest

    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

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

    Any tips would be welcome

    jdlwright, Jun 12, 2006
    1. Advertisements

  2. 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.
    Steve C. Orr [MVP, MCSD], Jun 12, 2006
    1. Advertisements

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

    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 (
    bruce barker \(\), Jun 13, 2006
  4. jdlwright

    jdlwright Guest

    I wish that were the case, but no, it's a 'bug' in the framework

    calling Collect helps keep the total usage down (according to my

    jdlwright, Jun 13, 2006
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.