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

Alternate Freelist Implementation Idea #85

Open
phillipjohnston opened this issue Mar 30, 2022 · 0 comments
Open

Alternate Freelist Implementation Idea #85

phillipjohnston opened this issue Mar 30, 2022 · 0 comments

Comments

@phillipjohnston
Copy link
Member

From #82:

One way around the whole static problem would be to let the user provide the memory for the metadata themselves. That would also make it easier to use libmemory in a multitasking environment without the need for locks (but of course would require some API changes/additions).

I like this idea, but it does require API changes, probably significant enough that it does not really work in this way as a "malloc". We could make the stock malloc APIs work with a single freelist (probably still requiring a lock in this case), but could provide extended APIs that allow callers to allocate memory against a particular freelist. Then each thread can have its own freelist and memory allocation zone.

This has some beneficial properties:

  • no lock needed if each thread provides its own freelist
  • you can portion dynamic memory according to each thread's specific needs
  • you can see how dynamic memory is being used across threads without any real effort put into analytics development - unlike a single heap case
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant