@@ -1577,7 +1577,7 @@ size_t Environment::NearHeapLimitCallback(void* data,
1577
1577
// may eventually crash with this new limit - effectively raising
1578
1578
// the heap limit to the new one.
1579
1579
if (env->is_processing_heap_limit_callback_ ) {
1580
- size_t new_limit = initial_heap_limit + max_young_gen_size;
1580
+ size_t new_limit = current_heap_limit + max_young_gen_size;
1581
1581
Debug (env,
1582
1582
DebugCategory::DIAGNOSTICS,
1583
1583
" Not generating snapshots in nested callback. "
@@ -1595,7 +1595,9 @@ size_t Environment::NearHeapLimitCallback(void* data,
1595
1595
" Not generating snapshots because it's too risky.\n " );
1596
1596
env->isolate ()->RemoveNearHeapLimitCallback (NearHeapLimitCallback,
1597
1597
initial_heap_limit);
1598
- return current_heap_limit;
1598
+ // The new limit must be higher than current_heap_limit or V8 might
1599
+ // crash.
1600
+ return current_heap_limit + 1 ;
1599
1601
}
1600
1602
1601
1603
// Take the snapshot synchronously.
@@ -1631,7 +1633,10 @@ size_t Environment::NearHeapLimitCallback(void* data,
1631
1633
env->isolate ()->AutomaticallyRestoreInitialHeapLimit (0.95 );
1632
1634
1633
1635
env->is_processing_heap_limit_callback_ = false ;
1634
- return initial_heap_limit;
1636
+
1637
+ // The new limit must be higher than current_heap_limit or V8 might
1638
+ // crash.
1639
+ return current_heap_limit + 1 ;
1635
1640
}
1636
1641
1637
1642
inline size_t Environment::SelfSize () const {
0 commit comments