<commit_before># Memory management

## Heap pointer
- do not use register pinning to store heap pointer
- instead always pass heap pointer as a function argument
  - each thread has own heap and heap pointer
  - save heap pointer to a global variable when calling foreign function

## Compile time garbage collection
[ASAP: As Static As Possible memory management](http://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-908.html)

related: [Dead data elimination](http://nbviewer.jupyter.org/github/grin-tech/grin/blob/master/papers/MoL-2010-19.text.pdf#page=55) in [A modern back-end for a dependently typed language](http://nbviewer.jupyter.org/github/grin-tech/grin/blob/master/papers/MoL-2010-19.text.pdf)<commit_msg>Update MemoryManagement.md<commit_after># Memory management

## Heap pointer
- do not use register pinning to store heap pointer
- instead always pass heap pointer as a function argument
  - each thread has own heap and heap pointer
  - save heap pointer to a global variable when calling foreign function

## Compile time garbage collection
[ASAP: As Static As Possible memory management](http://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-908.html)

related: [Dead data elimination](http://nbviewer.jupyter.org/github/grin-tech/grin/blob/master/papers/MoL-2010-19.text.pdf#page=55) in [A modern back-end for a dependently typed language](http://nbviewer.jupyter.org/github/grin-tech/grin/blob/master/papers/MoL-2010-19.text.pdf)

## Sample Project
[Sample project](https://github.com/robinvd/lang-experiments) for LLVM stack map based GC.
{'fraction_non_alphanumeric': 0.1078114912846998, 'fraction_numerical': 0.02194964493221433, 'mean_word_length': 4.615942028985507, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5361474', 'n_tokens_mistral': 508, 'n_tokens_neox': 472, 'n_words': 142}