You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
abort('Cannot enlarge memory arrays, since compiling with pthreads support enabled (-s USE_PTHREADS=1).');
478
+
#else
479
+
#if ALLOW_MEMORY_GROWTH==0
480
+
#if ABORTING_MALLOC
481
+
abortOnCannotGrowMemory();
482
+
#else
483
+
returnfalse;// malloc will report failure
484
+
#endif
485
+
#else
486
+
varoldSize=_emscripten_get_heap_size();
487
+
// TOTAL_MEMORY is the current size of the actual array, and DYNAMICTOP is the new top.
488
+
#if ASSERTIONS
489
+
assert(requestedSize>oldSize);// This function should only ever be called after the ceiling of the dynamic heap has already been bumped to exceed the current total size of the asm.js heap.
490
+
#endif
491
+
492
+
#if EMSCRIPTEN_TRACING
493
+
// Report old layout one last time
494
+
_emscripten_trace_report_memory_layout();
495
+
#endif
496
+
497
+
varPAGE_MULTIPLE={{{ getPageSize()}}};
498
+
varLIMIT=2147483648-PAGE_MULTIPLE;// We can do one page short of 2GB as theoretical maximum.
499
+
500
+
if(requestedSize>LIMIT){
501
+
#if ASSERTIONS
502
+
err('Cannot enlarge memory, asked to go up to '+requestedSize+' bytes, but the limit is '+LIMIT+' bytes!');
503
+
#endif
504
+
returnfalse;
505
+
}
506
+
507
+
varMIN_TOTAL_MEMORY=16777216;
508
+
varnewSize=Math.max(oldSize,MIN_TOTAL_MEMORY);// So the loop below will not be infinite, and minimum asm.js memory size is 16MB.
509
+
510
+
while(newSize<requestedSize){// Keep incrementing the heap size as long as it's less than what is requested.
511
+
if(newSize<=536870912){
512
+
newSize=alignUp(2*newSize,PAGE_MULTIPLE);// Simple heuristic: double until 1GB...
513
+
}else{
514
+
// ..., but after that, add smaller increments towards 2GB, which we cannot reach
warnOnce('Cannot ask for more memory since we reached the practical limit in browsers (which is just below 2GB), so the request would have failed. Requesting only '+TOTAL_MEMORY);
519
+
}
520
+
#endif
521
+
}
522
+
}
523
+
524
+
#if WASM_MEM_MAX!=-1
525
+
// A limit was set for how much we can grow. We should not exceed that
526
+
// (the wasm binary specifies it, so if we tried, we'd fail anyhow). That is,
527
+
// if we are at say 64MB, and the max is 100MB, then we should *not* try to
528
+
// grow 64->128MB which is the default behavior (doubling), as 128MB will
529
+
// fail because of the max limit. Instead, we should only try to grow
530
+
// 64->100MB in this example, which has a chance of succeeding (but may
531
+
// still fail for another reason, of actually running out of memory).
532
+
newSize=Math.min(newSize,{{{WASM_MEM_MAX}}});
533
+
if(newSize==oldSize){
534
+
#if ASSERTIONS
535
+
err('Failed to grow the heap from '+oldSize+', as we reached the WASM_MEM_MAX limit ('+{{{WASM_MEM_MAX}}}+') set during compilation');
Copy file name to clipboardExpand all lines: src/preamble.js
-109Lines changed: 0 additions & 109 deletions
Original file line number
Diff line number
Diff line change
@@ -831,7 +831,6 @@ function stackTrace() {
831
831
varPAGE_SIZE=16384;
832
832
varWASM_PAGE_SIZE={{{WASM_PAGE_SIZE}}};
833
833
varASMJS_PAGE_SIZE={{{ASMJS_PAGE_SIZE}}};
834
-
varMIN_TOTAL_MEMORY=16777216;
835
834
836
835
functionalignUp(x,multiple){
837
836
if(x%multiple>0){
@@ -959,110 +958,6 @@ if (!Module['reallocBuffer']) Module['reallocBuffer'] = function(size) {
959
958
#endif // ALLOW_MEMORY_GROWTH
960
959
#endif // WASM == 0
961
960
962
-
functionenlargeMemory(){
963
-
#if USE_PTHREADS
964
-
abort('Cannot enlarge memory arrays, since compiling with pthreads support enabled (-s USE_PTHREADS=1).');
965
-
#else
966
-
#if ALLOW_MEMORY_GROWTH==0
967
-
#if ABORTING_MALLOC
968
-
abortOnCannotGrowMemory();
969
-
#else
970
-
returnfalse;// malloc will report failure
971
-
#endif
972
-
#else
973
-
// TOTAL_MEMORY is the current size of the actual array, and DYNAMICTOP is the new top.
974
-
#if ASSERTIONS
975
-
assert(HEAP32[DYNAMICTOP_PTR>>2]>TOTAL_MEMORY);// This function should only ever be called after the ceiling of the dynamic heap has already been bumped to exceed the current total size of the asm.js heap.
976
-
#endif
977
-
978
-
#if EMSCRIPTEN_TRACING
979
-
// Report old layout one last time
980
-
_emscripten_trace_report_memory_layout();
981
-
#endif
982
-
983
-
varPAGE_MULTIPLE={{{ getPageSize()}}};
984
-
varLIMIT=2147483648-PAGE_MULTIPLE;// We can do one page short of 2GB as theoretical maximum.
985
-
986
-
if(HEAP32[DYNAMICTOP_PTR>>2]>LIMIT){
987
-
#if ASSERTIONS
988
-
err('Cannot enlarge memory, asked to go up to '+HEAP32[DYNAMICTOP_PTR>>2]+' bytes, but the limit is '+LIMIT+' bytes!');
989
-
#endif
990
-
returnfalse;
991
-
}
992
-
993
-
varOLD_TOTAL_MEMORY=TOTAL_MEMORY;
994
-
TOTAL_MEMORY=Math.max(TOTAL_MEMORY,MIN_TOTAL_MEMORY);// So the loop below will not be infinite, and minimum asm.js memory size is 16MB.
995
-
996
-
while(TOTAL_MEMORY<HEAP32[DYNAMICTOP_PTR>>2]){// Keep incrementing the heap size as long as it's less than what is requested.
997
-
if(TOTAL_MEMORY<=536870912){
998
-
TOTAL_MEMORY=alignUp(2*TOTAL_MEMORY,PAGE_MULTIPLE);// Simple heuristic: double until 1GB...
999
-
}else{
1000
-
// ..., but after that, add smaller increments towards 2GB, which we cannot reach
warnOnce('Cannot ask for more memory since we reached the practical limit in browsers (which is just below 2GB), so the request would have failed. Requesting only '+TOTAL_MEMORY);
1005
-
}
1006
-
#endif
1007
-
}
1008
-
}
1009
-
1010
-
#if WASM_MEM_MAX!=-1
1011
-
// A limit was set for how much we can grow. We should not exceed that
1012
-
// (the wasm binary specifies it, so if we tried, we'd fail anyhow). That is,
1013
-
// if we are at say 64MB, and the max is 100MB, then we should *not* try to
1014
-
// grow 64->128MB which is the default behavior (doubling), as 128MB will
1015
-
// fail because of the max limit. Instead, we should only try to grow
1016
-
// 64->100MB in this example, which has a chance of succeeding (but may
1017
-
// still fail for another reason, of actually running out of memory).
0 commit comments