views:

44

answers:

2

In a previous question I asked possible programatic ways of maximising the largest block allocatable on the LOH. I'm still seeing the problems, but now I'm trying to get my head around why the LOH seems to grow and shrink in size, yet I'm still seeing OutOfMemoryExceptions that tally with what others have reported as being due to LOH fragmentation.

Why might one call to, for example, StringBuilder.EnsureCapacity throw an OutOfMemoryException for me, but another call from somewhere else result in the LOH expanding in size (according to the performance counters, it is growing and shrinking)?

A: 

im not sure but i would try 2 ways:

  1. check for allocated unmanaged memory in your application and use the GC.AddMemoryPressure Method to tell the memorymanagment to handle this better.
  2. use the MemoryFailPoint Class prior to your big allocation calls. there you have a chance to avoid a big boom in your application. release some ressources and try it again.

edit: a 3rd way may be to create more appdomains and to handle that big stuff in that extra appdomains.

Jack
A: 

I went to the original article and posted what I think might be your problem there. Go check it out.

Flory