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
Copy file name to clipboardExpand all lines: docs/contributor/memory_management.md
+3-5Lines changed: 3 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ We ultimately aim to replace Grain's bespoke memory management with the WebAssem
6
6
7
7
## Memory Allocator
8
8
9
-
Grain uses a [memory allocator](https://github.com/grain-lang/grain/blob/main/stdlib/runtime/malloc.gr)derived from the `malloc`/`free` example given in Kernighan and Ritchie's ["The C Programming Language"](https://kremlin.cc/k&r.pdf) (K&R C), pages 185-188 (PDF page 199). This module exports the following values:
9
+
More documentation about Grain's [memory allocator](https://github.com/grain-lang/grain/blob/main/stdlib/runtime/malloc.gr)can be found in that module. It exports the following values:
* Returns the current free list pointer (used for debugging)
35
-
*
36
-
* @returns The free list pointer
34
+
* Leaks all memory in all free lists; used for testing.
37
35
*/
38
-
export let getFreePtr = () => WasmI32
36
+
export let leakAll = () => Void
39
37
```
40
38
41
39
These functions should be familiar to programmers who have used `malloc` and `free` in C (and C-like languages). For further reading, refer to this Wikipedia page: [C dynamic memory allocation](https://en.wikipedia.org/wiki/C_dynamic_memory_allocation). The semantics of these functions align near-identically with those of C's corresponding functions.
0 commit comments