Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve memory management #160

Open
SanderMertens opened this issue Feb 13, 2015 · 0 comments
Open

Improve memory management #160

SanderMertens opened this issue Feb 13, 2015 · 0 comments

Comments

@SanderMertens
Copy link
Member

Objects are being memory managed using reference counting. When an object reaches reference count zero it will be destructed. The current approach has however some issues.

First and foremost cycles are not being collected. Since proper detection and collection of cycles requires a "stop the world" approach in some way or another where all operations are halted while the garbage collector is doing its work, this will be tricky to implement.

If a cycle detector is implemented, a very carefully designed algorithm must be put in place that properly destructs objects in a cycle. The issue here is that when A is pointing to B, and B to A, then A is destructed, then B is destructed, and B accesses A in its destructor, there is a potential for error.

To solve this, object destructors must be resilient against encountering objects for which the destructor has been called. Cleaning up resources can only occur after for all objects in a cycle the destructor has been called.

For those applications where garbage collection is undesirable, weak references shall be supported. A weak reference shall update its value to null upon destruction of the object it is pointing to.

@SanderMertens SanderMertens added this to the Alpha release 0.4.0 milestone Feb 13, 2015
@SanderMertens SanderMertens modified the milestones: alpha 0.3.0, alpha 0.4.0 Oct 25, 2015
@SanderMertens SanderMertens removed this from the alpha 0.3.0 milestone Feb 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant