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
{{ message }}
Repository navigation
enlargeMemory does not update Module["HEAP8"] and others #713
When enlargeMemory() gets called, it updates the HEAP8, HEAP16 etc. global variables, but does not update the Module["HEAP8"], Module["HEAP16"] etc. values. This prevents callers to change/retrieve the contents of the heap after the memory has been enlarged.
A way to solve this:
function enlargeMemory() {
while (TOTAL_MEMORY <= STATICTOP) {
TOTAL_MEMORY = alignMemoryPage(2 * TOTAL_MEMORY);
}
var oldHEAP8 = HEAP8;
var buffer = new ArrayBuffer(TOTAL_MEMORY);
HEAP8 = new Int8Array(buffer);
HEAP16 = new Int16Array(buffer);
HEAP32 = new Int32Array(buffer);
HEAPU8 = new Uint8Array(buffer);
HEAPU16 = new Uint16Array(buffer);
HEAPU32 = new Uint32Array(buffer);
HEAPF32 = new Float32Array(buffer);
HEAPF64 = new Float64Array(buffer);
HEAP8.set(oldHEAP8);
// +++++++++++++++++++
Module["HEAP8"] = HEAP8;
Module["HEAP16"] = HEAP16;
Module["HEAP32"] = HEAP32;
Module["HEAPU8"] = HEAPU8;
Module["HEAPU16"] = HEAPU16;
Module["HEAPU32"] = HEAPU32;
Module["HEAPF32"] = HEAPF32;
Module["HEAPF64"] = HEAPF64;
// +++++++++++++++++++
}
Activity
kripken commentedon Nov 16, 2012
Thanks for reporting!
lptr commentedon Nov 16, 2012
Wow, thanks for the quick fix. :)