Can heap managing be made more efficient?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
ghzcrlvct
Posts: 5
Joined: Fri Oct 09, 2020 9:44 am

Can heap managing be made more efficient?

Post by ghzcrlvct »

Not developing an OS myself, but as far as I know linked lists are commonly used for heap management, with each node being stored before the actual heap block a user allocates.

Is there some way this method seems to be so commonly used? Is there not a better way to manage a heap out there?
klange
Member
Member
Posts: 679
Joined: Wed Mar 30, 2011 12:31 am
Libera.chat IRC: klange
Discord: klange

Re: Can heap managing be made more efficient?

Post by klange »

Heaps made of linked lists are only a simple beginner implementation. Real heap implementations don't work that way and have been tuned for various performance properties.
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: Can heap managing be made more efficient?

Post by Octacone »

People (not beginners) typically use self-balancing binary trees. Such as AVL trees, red black trees, splay trees, AA-trees etc...
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
User avatar
bzt
Member
Member
Posts: 1584
Joined: Thu Oct 13, 2016 4:55 pm
Contact:

Re: Can heap managing be made more efficient?

Post by bzt »

ghzcrlvct wrote:each node being stored before the actual heap block a user allocates.
That's pretty specific to Doug Lea's malloc and its successor, ptmalloc which was based on it. Most allocators don't do that (like Hoard, jemalloc etc.).

The Linux kernel for example uses linked lists of slabs, one node per partition (each partition stores allocations of the same quantum size, called slabs).

My allocator for example never mixes node data with application data, and it doesn't use linked lists at all (it has three different node types depending on quantum size).

Cheers,
bzt
Post Reply