+ /* Set the maximum blocks for the oldest generation, based on twice
+ * the amount of live data now, adjusted to fit the maximum heap
+ * size if necessary.
+ *
+ * This is an approximation, since in the worst case we'll need
+ * twice the amount of live data plus whatever space the other
+ * generations need.
+ */
+ oldest_gen->max_blocks =
+ stg_max(oldest_gen->steps[0].to_blocks * 2,
+ RtsFlags.GcFlags.minAllocAreaSize * 4);
+ if (oldest_gen->max_blocks > RtsFlags.GcFlags.maxHeapSize / 2) {
+ oldest_gen->max_blocks = RtsFlags.GcFlags.maxHeapSize / 2;
+ if (((int)oldest_gen->max_blocks - (int)oldest_gen->steps[0].to_blocks) <
+ (RtsFlags.GcFlags.pcFreeHeap *
+ RtsFlags.GcFlags.maxHeapSize / 200)) {
+ heapOverflow();
+ }
+ }
+