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

[libc] Add arena-based memory allocator for OpenWatcom large model #2138

Merged
merged 7 commits into from
Dec 17, 2024

Conversation

ghaerr
Copy link
Owner

@ghaerr ghaerr commented Dec 16, 2024

The new "amalloc" arena allocator is finally implemented and working! This PR adds the capability of managing lots of small allocations in up to a 64K block (arena) of memory obtained through fmemalloc at startup. This will allow for a set of wrapper routines to be used to either allocate small allocations, up to 64k worth from this allocator, while directly allocating large blocks from fmemalloc itself. That threshold will be dynamically adjustable for each application.

In addition, a very comprehensive "debug malloc" is introduced using code from the previously existing-but-not-well-integrated UNIX v7 malloc classic algorithm. amalloc also contains the same heap integrity checking and walking code. The debug display output can be dynamically turned on using sysctl malloc.debug=2 from the shell for basic allocation summary, and =3 for a detailed heap dump after every allocation or free.

A general replacement of realloc and a few top-level wrapper routines will be required for this to be seamlessly integrated into the 8086 toolchain, coming in another PR.

Tested on OWC. Not ready for use with ia16-elf-gcc (small model) applications.

@ghaerr ghaerr merged commit 6757020 into master Dec 17, 2024
2 checks passed
@ghaerr ghaerr deleted the malloc branch December 17, 2024 01:01
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

Successfully merging this pull request may close these issues.

1 participant