Memory management #49
-
How is the generation handling reference counting? Is the memory of an object automatically freed when the javascript pointer to is is also freed? Or should I manage my memory manually? Thanks! P.S. Thanks for your work! It is great not to have to put my hands too deep in the C code 😉. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hey! JavaScript doesn't currently provide a simple way to hook into the garbage collection process. Therefore, there is no automatic freeing of memory, which you allocated via JS using This memory is not immediately available again to be used by the browser and/or operating system: Maybe it would be possible to implement automatic memory management using JavaScript |
Beta Was this translation helpful? Give feedback.
Hey!
JavaScript doesn't currently provide a simple way to hook into the garbage collection process. Therefore, there is no automatic freeing of memory, which you allocated via JS using
const myObject = new openCascade.AnyClass()
. I.e. you have to callmyObject.delete()
when you don't need this object any longer.This memory is not immediately available again to be used by the browser and/or operating system:
When instantiating the WebAssembly module, a chunk of memory is created and assigned to it via a JavaScript ArrayBuffer. This ArrayBuffer has an initial size from which it can grow - however it can never shrink (I believe, this is a limitation of the WebAssembly spec). I.e. when you're
…