alloc_context* acontext, heap_segment* seg,
int align_const, int gen_number)
{
+ size_t aligned_min_obj_size = Align(min_obj_size, align_const);
+
//probably should pass seg==0 for free lists.
if (seg)
{
}
dprintf (3, ("Expanding segment allocation [%Ix, %Ix[", (size_t)start,
- (size_t)start + limit_size - Align (min_obj_size, align_const)));
+ (size_t)start + limit_size - aligned_min_obj_size));
if ((acontext->alloc_limit != start) &&
- (acontext->alloc_limit + Align (min_obj_size, align_const))!= start)
+ (acontext->alloc_limit + aligned_min_obj_size)!= start)
{
uint8_t* hole = acontext->alloc_ptr;
if (hole != 0)
dprintf (3, ("filling up hole [%Ix, %Ix[", (size_t)hole, (size_t)hole + size + Align (min_obj_size, align_const)));
// when we are finishing an allocation from a free list
// we know that the free area was Align(min_obj_size) larger
- size_t free_obj_size = size + Align (min_obj_size, align_const);
+ acontext->alloc_bytes -= size;
+ size_t free_obj_size = size + aligned_min_obj_size;
make_unused_array (hole, free_obj_size);
generation_free_obj_space (generation_of (gen_number)) += free_obj_size;
}
acontext->alloc_ptr = start;
}
- acontext->alloc_limit = (start + limit_size - Align (min_obj_size, align_const));
- acontext->alloc_bytes += limit_size;
+ acontext->alloc_limit = (start + limit_size - aligned_min_obj_size);
+ acontext->alloc_bytes += limit_size - ((gen_number < max_generation + 1) ? aligned_min_obj_size : 0);
#ifdef FEATURE_APPDOMAIN_RESOURCE_MONITORING
if (g_fEnableARM)
<Member Name="Collect(System.Int32,System.GCCollectionMode,System.Boolean)" />
<Member Name="Collect(System.Int32,System.GCCollectionMode,System.Boolean,System.Boolean)" />
<Member Name="CollectionCount(System.Int32)" />
+ <Member Name="GetAllocatedBytesForCurrentThread" />
<Member Name="GetGeneration(System.Object)" />
<Member Name="GetGeneration(System.WeakReference)" />
<Member Name="get_MaxGeneration" />
[System.Security.SecurityCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall)]
+ private static extern long _GetAllocatedBytesForCurrentThread();
+
+ [System.Security.SecuritySafeCritical] // auto-generated
+ public static long GetAllocatedBytesForCurrentThread() {
+ return _GetAllocatedBytesForCurrentThread();
+ }
+
+ [System.Security.SecurityCritical] // auto-generated
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern bool _RegisterForFullGCNotification(int maxGenerationPercentage, int largeObjectHeapPercentage);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
}
FCIMPLEND
+/*===============================GetAllocatedBytesForCurrentThread===============================
+**Action: Computes the allocated bytes so far on the current thread
+**Returns: The allocated bytes so far on the current thread
+**Arguments: None
+**Exceptions: None
+==============================================================================*/
+FCIMPL0(INT64, GCInterface::GetAllocatedBytesForCurrentThread)
+{
+ FCALL_CONTRACT;
+
+ INT64 currentAllocated = 0;
+ Thread *pThread = GetThread();
+ alloc_context* ac = pThread->GetAllocContext();
+ currentAllocated = ac->alloc_bytes + ac->alloc_bytes_loh - (ac->alloc_limit - ac->alloc_ptr);
+
+ return currentAllocated;
+}
+FCIMPLEND
/*==============================SuppressFinalize================================
**Action: Indicate that an object's finalizer should not be run by the system
static FCDECL1(void, ReRegisterForFinalize, Object *obj);
static FCDECL2(int, CollectionCount, INT32 generation, INT32 getSpecialGCCount);
+ static FCDECL0(INT64, GetAllocatedBytesForCurrentThread);
+
static
int QCALLTYPE StartNoGCRegion(INT64 totalSize, BOOL lohSizeKnown, INT64 lohSize, BOOL disallowFullBlockingGC);
FCFuncElement("_SuppressFinalize", GCInterface::SuppressFinalize)
FCFuncElement("_ReRegisterForFinalize", GCInterface::ReRegisterForFinalize)
+ FCFuncElement("_GetAllocatedBytesForCurrentThread", GCInterface::GetAllocatedBytesForCurrentThread)
FCFuncEnd()
#ifndef FEATURE_CORECLR