> I don't think that you have this level of control. I don't see any reason
> why this would be useful either. The memory manager must be properly
[quoted text clipped - 12 lines]
> Thanks,
> Frank
The problem is that the LOH is not designed to handle lots of small objects.
So, you may run into more severe problems (like fragmentation problems) if
you use the LOH for your small object allocations. If the real time
constraints on your app are so severe that you cannot afford the compaction
phase, maybe this means that you app is not suitable for a managed
environment, or that you must manage your memory differently (like
allocating big arrays of structs instead of allocating objects
individually).
BTW our app also has a very large memory footprint (between 500MB and 1GB)
and we see the compaction hit, but we can live with it (this is a web
server, so the user can take a 1-2 second hit once in while (every 10
minutes or less often, depending on the load).
Bruno.
> Bruno,
>
[quoted text clipped - 32 lines]
> > Thanks,
> > Frank
Frank - 02 Aug 2004 05:10 GMT
Bruno,
Like you said, perhaps our app is not suitable for a managed environment.
I am assuming the LOH will become fragmented, whether you allocate large
objects or small objects (perhaps more quickly with small objects). But even
if we use an unmanaged environment (e.g., C++ heap) we would still have a
fragmentation problem. In other words, the C++ heap would fragment just as
easily as the C# LOH. So, if we are going to contend with fragmentation
anyway, may as well do it in C# where you also get the benefits of
generational garbage collection.
I think it would be a great feature if .NET would let you specify which heap
to allocate on. If that happened, the LOH should be called the
No-Compact-Heap. It would also be nice if you could specify/inject a custom
garbage collector for an AppDomain.
-Frank
> The problem is that the LOH is not designed to handle lots of small objects.
> So, you may run into more severe problems (like fragmentation problems) if
[quoted text clipped - 11 lines]
>
> Bruno.
Niall - 03 Aug 2004 03:42 GMT
As Bruno says, you may have to look at things like pre-allocation. If you
know you will need a lot of instances of SmallObject, it may improve your
performance a lot to allocate roughly the required number at startup. Then,
instead of instantiating new objects when needed, you reuse the old ones. By
allocating at startup, you put the memory at the beginning of the heap, and
hence there is little chance it will have to move during a heap compaction.
Niall
> The problem is that the LOH is not designed to handle lots of small objects.
> So, you may run into more severe problems (like fragmentation problems) if
[quoted text clipped - 4 lines]
> allocating big arrays of structs instead of allocating objects
> individually).
> I am working on an app that MUST be responsive at all times. Our application
> has a very large managed memory footprint (> 1GB of small objects). We are
> seeing that our app hangs for a couple of seconds when the garbage collector
> compacts heap.
What type of application are you building? Windows Service / WinForms /
ASP.NET ?
If you're a Windows Service, you might look into the "Server CLR" rather
than the "Workstation CLR". This will (in most cases) greatly improve your
garbage collection performance on multi-processor machines.

Signature
Chris Mullins