Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / CLR / August 2004

Tip: Looking for answers? Try searching our database.

RE: Forcing a Large Object Heap allocation

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bruno Jouhier [MVP] - 01 Aug 2004 12:12 GMT
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
encapsulated and should not expose this level of detail. Why do you need
this?

Bruno.

De: "Frank" <google@xemaps.com>
Objet: Forcing a Large Object Heap allocation
Date: Sunday, August 01, 2004 6:44 AM

Does anyone know if it is possible to force a small object to be allocated
on the Large Object Heap (LOH)?

Thanks,
Frank
Frank - 01 Aug 2004 18:05 GMT
Bruno,

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. Since our app must remain responsive we would rather take the
hit of allocating on the LOH and avoid the "compacting" phase all together.
The LOH has been described as being more similar to the C++ heap, which is
what we want. However, we want to try to avoid making calls into unmanaged
code for all our allocations and deallocations. Pinning many small objects
in the regular heap causes poorer performance than allocating many large
objects in the LOH.

Is there any way to avoid the ~2 second pause caused by the compacting
process?

Thanks,

Frank

> 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
Bruno Jouhier [MVP] - 01 Aug 2004 20:55 GMT
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).
Chris Mullins - 02 Aug 2004 17:54 GMT
> 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


Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.