-
-
Notifications
You must be signed in to change notification settings - Fork 73
C: Implement merging arena pages #719
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
base: main
Are you sure you want to change the base?
Conversation
58b5bf9 to
b6ab2d0
Compare
f31b7bb to
0255d2c
Compare
src/util/hb_arena.c
Outdated
| if (allocator->tail->next != NULL && hb_arena_page_has_capacity(allocator->tail->next, required_size)) { | ||
| allocator->tail = allocator->tail->next; | ||
| } else { | ||
| bool allocated = hb_arena_append_page(allocator, required_size); |
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.
TODO: Potential memory leak.
In a situation where the tail has a next page, but the page does not have a sufficient capacity , we would just override the page next pointer and leak the existing page that didn't have enough capacity to hold the value
Reference: append_page implementation
https://github.com/marcoroth/herb/pull/719/files#diff-38530fcdce39968fc659335346b4b6c0d6be9af0f16e2ed1354ca3bb693b2461R78
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.
I think that should be addressed with this: https://github.com/marcoroth/herb/compare/f1f5b6a9c95c05728ffae8dde5911aab5704010f..e1cbb82b82f97ddea4c2d61b6352a54769a0d13f
Whenever we reset to the arena to a given point we consolidate all pages that got freed up into one page, allowing us to have larger chunks of contiguous memory.
ac26b20 to
761fb2f
Compare
Based on the arena pages proposed in #708 by @marcoroth, this PR builds on the concept and adds a more refined reset behavior that merges obsolete pages into one big page.
This has the advantage that we won't have a bunch of small pages, and instead have more contiguous memory available.
How it works
For now the first page is never deallocated and merged into a bigger page for two reasons: