summaryrefslogtreecommitdiff
path: root/test/grow_memory.cpp
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2016-03-22 15:20:00 -0700
committerAlon Zakai <alonzakai@gmail.com>2016-03-22 15:20:00 -0700
commit468e0dde46724e2a40fa311a878d0d50cac8f831 (patch)
tree2c9b0a6aa78dd1fd2da9dc71a5bbea41e4384aac /test/grow_memory.cpp
parent94bf9d12986fb069323738247bea5a480cfd8ef6 (diff)
parent3cde7acb07202af8f04f73eaaa9c7579e19a32cf (diff)
downloadbinaryen-468e0dde46724e2a40fa311a878d0d50cac8f831.tar.gz
binaryen-468e0dde46724e2a40fa311a878d0d50cac8f831.tar.bz2
binaryen-468e0dde46724e2a40fa311a878d0d50cac8f831.zip
Merge pull request #273 from WebAssembly/memory-growth
Fix and test memory growth
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");
+}
+