# Custom allocator for wasm

**URL:** https://discourse.vtk.org/t/custom-allocator-for-wasm/14186
**Category:** vtk.wasm
**Created:** [July 9, 2024, 3:03am UTC](https://discourse.vtk.org/t/custom-allocator-for-wasm/14186 "2024-07-09T03:03:07Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Jens\_Munk\_Hansen](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jens_munk_hansen/32/1215_2.png) [@Jens\_Munk\_Hansen](https://discourse.vtk.org/u/Jens_Munk_Hansen)
#### Post date: [July 9, 2024, 3:03am UTC](https://discourse.vtk.org/t/custom-allocator-for-wasm/14186/1 "2024-07-09T03:03:07Z")

</div>

Just throwing out a question knowing that WASM does not support virtual memory.

Is there a benefit of compling VTK wasm using memkind? Or perhaps another allocator?

Anyone with experience in this area?

Thanks in advance  
Jens

---

<div class="post-metadata">

### Author: ![jaswantp](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jaswantp/32/10046_2.png) [@jaswantp](https://discourse.vtk.org/u/jaswantp)
#### Post date: [July 9, 2024, 3:08am UTC](https://discourse.vtk.org/t/custom-allocator-for-wasm/14186/2 "2024-07-09T03:08:40Z")

</div>

i don’t know the best about memkind, but as far as wasm in browser goes, there’s just the ‘standard’ heap, which is backed by a javascript `Uint8Array`. Afaik, there’s no different kind of virtual memory available from js.

Probably wasi is a good platform that may support memkind.

---

<div class="post-metadata">

### Author: ![Jens\_Munk\_Hansen](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jens_munk_hansen/32/1215_2.png) [@Jens\_Munk\_Hansen](https://discourse.vtk.org/u/Jens_Munk_Hansen)
#### Post date: [July 9, 2024, 3:43am UTC](https://discourse.vtk.org/t/custom-allocator-for-wasm/14186/3 "2024-07-09T03:43:54Z")

</div>

As a start, I will create some heap fragmentation tests and see how thing goes. It really sounds scary that WASM doesn’t support virtual memory. I will experiment with different allocators and if I find a good solution, I will let you know. My current issue is that I am use an implicit function for drawing on a mesh and I fear that will be extremely slow on WASM. But again, it is nice that it is easy to globally replace the allocator in VTK
