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

Any pointers on an ARC design? #7

Closed
Gozala opened this issue Jan 20, 2018 · 4 comments
Closed

Any pointers on an ARC design? #7

Gozala opened this issue Jan 20, 2018 · 4 comments
Labels

Comments

@Gozala
Copy link

Gozala commented Jan 20, 2018

Is the mechanism based on some paper ? If so could you please share the details ?

Thanks

@appcypher
Copy link
Collaborator

There may be papers out there that explain this technique, but I'm not aware of any of them. Its just something I thought of and started implementing.

I like calling it Automatic Reference Journalling cos it does more than just counting references.
I've tested it on some simple programs and it worked quite well, however since I've not tried it on more complex programs, I can't claim that it will always work in all cases. I have a strong feeling it will though.

The problem with the method now is that it does deep analysis of each object which might hurt compile time, but then I've not spent enough time with it to optimize it.

@appcypher
Copy link
Collaborator

I'm closing this issue. I believe I've provided answer to the question asked.

@MaxGraey
Copy link

MaxGraey commented Jan 30, 2018

Hi, I have another question about ARC implementation.

How you resolve cyclic references which cause to memory leak without special hints? For example Objective-C/Swift use special week references define like:

@property (nonatomic, weak) NSObject* a;

Rust provide much wider patterns to resolve this like RefCell, Weak, and Rc.

Some languages like Alef/Limbo has ARC with fallback to GC for resolving this case.
Someone use cyclic reference counter (CRC)

So which way will you choose?

@appcypher
Copy link
Collaborator

appcypher commented Feb 5, 2018

Sorry, I got this late.

The ARC method I'm employing is not like Objective-C/Swift, nor like Alef/Limbo ARC-tracing hybrid.
I've tried looking for papers that explain the method I'm using and these papers come close:

• Detlefs, D. (2004). Automatic Inference of Reference-Count Invariants.
• Goldberg, B., & Park, Y.G. (1991). Reference Escape Analysis: Optimizing Reference Counting based on the Lifetime of References. PEPM.
• Joisha, P.G. (2008). A principled approach to nondeferred reference-counting garbage collection. VEE.

But none of them goes into details of how this can be extended to concurrent programs, which is the same caveat mine has.

For non-concurrent programs, objects can be freed deterministically without any runtime cost apart from calling free.

In concurrent programs, the system falls apart since an async function may free an object in use by another async function after it exits.

The exit order of invoked async functions can be unpredictable, so some sort of runtime synchronization is needed to handle that.

You may need to take a look at the first paper I linked, it describes my method well.
Maybe I will create time to explain what I have in mind later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants