Skip to content

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

Merged
ghaerr merged 7 commits intomasterfrom
malloc
Dec 17, 2024
Merged

[libc] Add arena-based memory allocator for OpenWatcom large model#2138
ghaerr merged 7 commits intomasterfrom
malloc

Conversation

@ghaerr
Copy link
Copy Markdown
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
@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