Comments (4)
That is totally correct comment, documentation is way beyond required.
Basically, there are two ways to work with memory management from c++ side, and two - from script side.
What we normally do from C++ side, is just call
context.restart();
context.restartHeaps();
on each "first run" (first in terms of call nesting, i.e. we are not calling it when script->c++->script).
That call will free all memory, and these calls are extremely cheap. With that no GC is needed at all.
The only thing required - is that there is no any global variables in script pointing to the heap (or better - no global variables at all).
The other possible way - is collect garbage (again, only from c++ side, i.e. explicit call is required). With that you can have global variables in script.
From inside script, there is option to call not only 'new', but also 'delete' (see tree benchmark).
That is unsafe, and so will require [unsafe] annotation.
We will try to make some documentation on that topic.
from dascript.
I prefer the the way “context.restart()” , it keep things simpler.
Thank you for your explanation!
from dascript.
Just don't forget restartHeaps() as well :)
from dascript.
Thanks for tips that will save me from bugs, I really thought a single "restart()" will work, I know the right way is calling them both:
context.restart();
context.restartHeaps();
from dascript.
Related Issues (20)
- try to AOT HOT 3
- Compilation error when exporting c++ class with ManagedStructureAnnotation HOT 1
- How to debug in an embedded environment using VSCode ? HOT 1
- cmake error ~~ help~~
- Which should I use “addExtern” or “addInterop”? HOT 1
- Unexpected execution when embedded module, Executed without being called~~ HOT 1
- No Garbage collection ? HOT 3
- where is libclang HOT 2
- 30304: function not found HOT 5
- How to correctly require the parent module or somewhere ? HOT 2
- How to export a array<c++ struct> to das ? HOT 3
- How to generate .wasm HOT 2
- How to list exported symbols from modules HOT 2
- How to compile simple program in AOT mode? HOT 6
- Are there any JIT mode optimizations flags? HOT 10
- Apparently cannot use libDaScript with CMake, when this is built as a dependency
- tutorial_07a crash because of das_structure_make() HOT 1
- Do away with python-style ident? HOT 1
- possible to benchmark memory use (and optionally multicore capabilties) HOT 1
- Failure generating Xcode 15.4 project
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dascript.