-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reconcile how LOH allocations are tracked in allocation contexts #13734
Comments
It appears that it does not, if you attempt to allocate an array that crosses the LOH threshold, it is not measured, which would explain why the allocations did not show in my benchmark in #13451 . using System;
class Program
{
static void Main(string[] args)
{
long before = GC.GetAllocatedBytesForCurrentThread();
var result = new char[50000];
long after = GC.GetAllocatedBytesForCurrentThread();
Console.WriteLine(before);
Console.WriteLine(after);
}
} a
Why shouldn't it? I would expect that it shows all allocations made on my current thread. |
the reason why AllocLHeap was there was to allocate objects smaller than LOH threshold on LOH. I have not looked at your PR yet, but I hope that was kept in mind. |
@Maoni0 - yes, forcing allocations of smaller objects to go into LOH is still possible. I also plan to use a similar mechanism (flags) as a way to request POH allocations. |
Fixed in #33402 |
Alloc
uses per-thread contextAllocLHeap
uses per-heap context.We probably should use only one way. Using per-heap context consistently is attractive, since we can make allocation contexts smaller by removing
alloc_bytes_loh
However, consider
GetAllocatedBytesForCurrentThread
API - does it actually see allocations done viaAllocLHeap
? Should it?The text was updated successfully, but these errors were encountered: