Visual Studio and .NET Framework Home
Large Object Heap (LOH) does not behave as expected for Double array placement
as By Design
3/30/2007 7:48:32 AM
User(s) can reproduce this bug
The Large Object Heap is used when any large object/arrays exceed over 85K. With that knowledge one can predict/map which generational heap a structure will be placed at. For example since a byte in .Net is one 'byte' in size, one can create an array of bytes such as
which will belong in the Generation 0 and not be placed in the LOH. But if one creates an array of bytes such as
That will be placed on the LOH. The same can be done for most all of other base types:
byte placed into generational heap 0 , larger allocations in the LOH - heap 2
int placed into generational heap 0 , larger allocations in the LOH - heap 2
float placed into generational heap 0 , larger allocations in the LOH - heap 2
char placed into generational heap 0 , larger allocations in the LOH - heap 2
decimal placed into generational heap 0 , larger allocations in the LOH - heap 2
The base byte size of the item dictates how large the array must be and those values shown above are as expected.
But the a double intrinsic of eight bytes should break around 10600 but it doesn't...it breaks at 1000. So when testing the double array:
double placed into generational heap 0 , larger allocations in the LOH - heap 2
This is not expected. Why does double fall even shorter than what Decimal, size 16, does?
Visual Studio 2005 (All Products and Editions) Service Pack 1
Windows XP Professional
Operating System Language
Steps to Reproduce
double array1K = new double;
Console.WriteLine(GC.GetGeneration(array1K)); // Returns 2
double array999 = new double;
Console.WriteLine(GC.GetGeneration(array999)); // Returns 0
1000 doubles get placed in LOH while 999 doubles do not.
Doubles 1 - ~10600 not in LOH in gen 0.
While doubles >~10600 fall into LOH and gen 2
TAP Code (if applicable)
You can indicate your satisfaction with how Microsoft handled this issue by completing this quick
3 question survey
to post a comment.
Please enter a comment.
on 4/4/2007 at 4:04 PM
The reason why double arrays are allocated on the LOH is because of performance. The LOH is alligned to 8 bytes so access to 'big' arrays is much faster if it is allocated on the LOH. We determined that the best tradeoff is when the array is bigger than 1000 elements.
Feel free to contact me directly if you have any other question.
CLR Performance & GC Program Manager
on 4/1/2007 at 11:30 PM
Thanks for your feedback. We have reproduced this bug on Visual Studio 2005 SP1, and we are sending this bug to the appropriate group within the VisualStudio Product Team for triage and resolution.
Visual Studio Product Team.
on 3/31/2007 at 10:46 PM
Thank you for your feedback. We are currently investigating. If this issue is urgent, please call support directly (see http://support.microsoft.com).
Visual Studio Product Team
to post a workaround.
Please enter a workaround.
© 2014 Microsoft