Comments (6)
Hey. Thanks for outlining this! It is indeed expected behavior right now and I'll queue it up to be documented in the book.
I'm not sure how to dynamically disallow such cycles. But I know some folks are interested in tinkering with integrating a gc, which to me would be the proper solution to dealing with cycles.
from rune.
Maybe weak references should be added in any case, even if cycles were not a problem?
from rune.
@vi I'm not against adding weak references. All though I personally don't use them very much. If anyone else wants to give it a stab, feel free!
from rune.
Note that most of the necessary plumbing to prevent the shared block from being de-allocated is already in place. All you'd really need to do for an initial implementation is try and take the interior value once the strong ref count reaches zero.
All though this has to be done in a way which doesn't change the size of the Shared<T>
container, which might be a little tricky since need to distinguish between strong and weak reference. Possibly smuggling an aligned pointer marker could be useful here. Which would be done by asserting that the pointer to SharedBox<T>
is aligned when created and mark weak references by setting the least significant bit.
from rune.
Started fiddling on the plumbing for a gc in the gc branch.
from rune.
This is a very interesting issue for scripting languages but seems to be practically unsolvable, given that even the most popular runtimes like CPython would fail on this (if you add at least one more layer like a list)
"Just" tracing doesn't help because you don't know when to run it. Running it to often would destroy performance. Running it when memory is low would introduce gigantic latencies and would make your memory usage go in waves from ~0 to 100%.
This leaves you with either heap generations to cope with "short lived" objects (like the JVM does) or escape analysis (like golang)... and a fully fledged GC. As long as every non-trivial value sits behind a Shared<> escape analysis (at least to a very shallow depth) is possible - given that you know how to track the value afterwards
The problem is that small but entangled memory leaks can be very hard to detect and trace. Big ones (like allocating in a loop) are easy to detect and solve with just a single manual drop.
from rune.
Related Issues (20)
- Standard macros should live in the `rune` crate and not `rune-modules`
- Vec is missing INDEX_GET protocol and support for range indexing HOT 4
- No warning or error when defining a variable multiple times in the same scope HOT 2
- Document built-in modules
- [question] Type conversion HOT 3
- Improve std::future::join HOT 5
- Proper way to call Rust from Rune Scripts HOT 1
- Language server should return `id` for unhandled requests HOT 3
- feature request: Integrate FlexStr
- item macros not working HOT 5
- Support non-qualified imports of macros and imports which happen after the macro is used HOT 4
- Formatting misfire with anything following item macro call HOT 9
- Ergonomics of macro implementation HOT 2
- Make derive macros work outside of `rune` HOT 4
- fs functions HOT 2
- Printable errors HOT 7
- Allow to iteration over functions available in loaded source HOT 3
- Attribute macro to generate rune module from rust module HOT 1
- Support raw strings
- Custom prelude HOT 1
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 rune.