memory.grow
Increase the size of the memory by adding new pages. Memory is made up of pages. Each page is 64Kb (64 * 1024 bytes).

Syntax

memory.grow

Stack In

i32 The number of pages to increase the memory by.

Stack Out

i32 The previous size of memory (in pages). If the value -1 is returned then the memory failed to grow.

Examples

;; Create memory 1 page in size and can grow to 20 pages
(memory 1 20)
  
;; Create function
(func $growMemory (result i32)
  ;; Set the number of pages to grow by
  i32.const 2

  ;; Grow the memory by 2 pages
  memory.grow

  ;; The stack contains an i32 value of 1
  ;; previous size of memory (in pages)
)