-
Notifications
You must be signed in to change notification settings - Fork 388
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
feat: GC #2735
feat: GC #2735
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2735 +/- ##
==========================================
+ Coverage 61.10% 61.19% +0.09%
==========================================
Files 564 566 +2
Lines 75355 75643 +288
==========================================
+ Hits 46045 46293 +248
- Misses 25946 25978 +32
- Partials 3364 3372 +8
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Co-authored-by: ltzmaxwell <[email protected]>
package main
func foo() {
s := []int{1, 2, 3}
}
func main() {
foo()
s1 := []int{4, 5, 6}
} in this one, should we also deallocate the underlying array as well? |
m.Alloc.heap.RemoveRoot(obj.tv) | ||
m.Alloc.DeallocatePointer() | ||
} | ||
} else if ho != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the usage of ho
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is used only for the comparison, for convenience.
I think the issue with this PR is that it's not "observable", there lacks some necessary tests. there should be a way to track what’s being allocated and deallocated, IMHO. |
What do you mean? Can you be more specific? |
The current test focuses on gc.go, but it’s insufficient to reveal what’s happening under the hood when dealing with specific code. e.g. package main
func foo() {
s := []int{1, 2, 3}
}
func main() {
foo()
s1 := []int{4, 5, 6}
} While the gc behavior is deterministic, it should be more observable. For instance, we could expose details like the current state of the allocator, metrics before and after memory allocation/deallocation, and more. What do you think? |
The only way i could see this being viable is if its behind a debug flag. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs a review from @jaekwon.
This approach was not approved by Jae so this PR is to be closed. |
Deterministic garbage collector for gnovm.
Tracks allocations and deallocates objects that aren't used anymore.
It implements a simple mark and sweep garbage collector.
Related issue
Root objects (objects through which heap allocated objects are accessed) are identified in each scope and are released at the end of that scope.
When a heap allocated object has no roots, it is considered garbage and it is deallocated.
Maps are not implemented here.
For simplicity for reviewing and merging, they will be added in a following PR.