summaryrefslogtreecommitdiff
path: root/test/grow_memory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/grow_memory.cpp')
-rw-r--r--test/grow_memory.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/grow_memory.cpp b/test/grow_memory.cpp
new file mode 100644
index 000000000..b8f732f7a
--- /dev/null
+++ b/test/grow_memory.cpp
@@ -0,0 +1,20 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <emscripten.h>
+
+volatile int writeOnly;
+
+int main() {
+ EM_ASM({
+ assert(HEAPU8.length === 16*1024*1024);
+ });
+ for (int i = 0; i < 20; i++) {
+ printf("alloc 1MB: %d\n", i);
+ writeOnly = (int)malloc(1024*1024);
+ }
+ EM_ASM({
+ assert(HEAPU8.length > 16*1024*1024);
+ });
+ printf("ok.\n");
+}
+