for (int gen = 0; gen <= limit; gen++)
{
size_t total_desired = 0;
+ size_t total_already_consumed = 0;
for (int i = 0; i < gc_heap::n_heaps; i++)
{
break;
}
total_desired = temp_total_desired;
+ // for gen 1 and gen 2, there may have been some incoming size
+ // already accounted for
+ assert ((ptrdiff_t)dd_desired_allocation (dd) >= dd_new_allocation (dd));
+ size_t already_consumed = dd_desired_allocation (dd) - dd_new_allocation (dd);
+ size_t temp_total_already_consumed = total_already_consumed + already_consumed;
+
+ // we should never have an overflow here as the consumed size should always fit in a size_t
+ assert (temp_total_already_consumed >= total_already_consumed);
+ total_already_consumed = temp_total_already_consumed;
}
size_t desired_per_heap = Align (total_desired/gc_heap::n_heaps,
get_alignment_constant (gen <= max_generation));
+ size_t already_consumed_per_heap = total_already_consumed / gc_heap::n_heaps;
+
if (gen == 0)
{
#if 1 //subsumed by the linear allocation model
dynamic_data* dd = hp->dynamic_data_of (gen);
dd_desired_allocation (dd) = desired_per_heap;
dd_gc_new_allocation (dd) = desired_per_heap;
- dd_new_allocation (dd) = desired_per_heap;
+ dd_new_allocation (dd) = desired_per_heap - already_consumed_per_heap;
if (gen == 0)
{
// When we are in the low latency mode, we can still be
// condemning more than gen1's 'cause of induced GCs.
dd_desired_allocation (dd) = low_latency_alloc;
+ dd_gc_new_allocation (dd) = dd_desired_allocation (dd);
+ dd_new_allocation (dd) = dd_gc_new_allocation (dd);
}
else
{
{
dd_desired_allocation (dd) = desired_new_allocation (dd, out, gen_number, 0);
}
+ dd_gc_new_allocation (dd) = dd_desired_allocation (dd);
+
+ // we may have had some incoming objects during this GC -
+ // adjust the consumed budget for these
+ dd_new_allocation (dd) = dd_gc_new_allocation (dd) - in;
}
gen_data->pinned_surv = dd_pinned_survived_size (dd);
gen_data->npinned_surv = dd_survived_size (dd) - dd_pinned_survived_size (dd);
- dd_gc_new_allocation (dd) = dd_desired_allocation (dd);
- dd_new_allocation (dd) = dd_gc_new_allocation (dd);
-
dd_promoted_size (dd) = out;
if (gen_number == max_generation)
{