Skip to content

Commit 1d996f5

Browse files
committed
src: properly configure default heap limits
Unless configured, V8 defaults to limiting the max heaps size to 700 MB or 1400MB on 32 and 64-bit platforms respectively. This default is based on the browser use-cases and doesn't make a lot of sense generally. This change properly configures the heap size based on actual available memory. PR-URL: #25576 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Yang Guo <[email protected]> Reviewed-By: Ujjwal Sharma <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent d0d84b0 commit 1d996f5

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/api/environment.cc

+9
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,15 @@ void FreeArrayBufferAllocator(ArrayBufferAllocator* allocator) {
8080
Isolate* NewIsolate(ArrayBufferAllocator* allocator, uv_loop_t* event_loop) {
8181
Isolate::CreateParams params;
8282
params.array_buffer_allocator = allocator;
83+
84+
double total_memory = uv_get_total_memory();
85+
if (total_memory > 0) {
86+
// V8 defaults to 700MB or 1.4GB on 32 and 64 bit platforms respectively.
87+
// This default is based on browser use-cases. Tell V8 to configure the
88+
// heap based on the actual physical memory.
89+
params.constraints.ConfigureDefaults(total_memory, 0);
90+
}
91+
8392
#ifdef NODE_ENABLE_VTUNE_PROFILING
8493
params.code_event_handler = vTune::GetVtuneCodeEventHandler();
8594
#endif

0 commit comments

Comments
 (0)