-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Closed
Description
#include <emscripten/emmalloc.h>
#include <stdio.h>
int main() {
// Allocate 32MB with 1MB alignment.
printf("%p\n", emmalloc_memalign(1024 * 1024, 32 * 1024 * 1024));
}Build with
./emcc a.c -sMALLOC=emmalloc -sWASM=0 -sINITIAL_MEMORY=128mb --profiling
and then edit a.out.js to add some logging at the top of function sbrk:
function sbrk($0) {
console.log('sbrk', $0);Running the program then shows
sbrk 48
sbrk 33554480
sbrk 33554480
0x100000
The initial sbrk is for emmalloc's internal data. Then we sbrk around 32MB, but then do so a second time for a total of 64MB.
This seems related to the high alignment, 1MB, as this does not happen without it.
This affects mimalloc when layered on emmalloc, since mimalloc does such large allocations with high alignment.
Metadata
Metadata
Assignees
Labels
No labels