Using the Hoard memory allocator with newlib

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
rdos
Member
Member
Posts: 3306
Joined: Wed Oct 01, 2008 1:55 pm

Using the Hoard memory allocator with newlib

Post by rdos »

I don't think the default malloc in newlib is any good, and the multithreading support is lousy and poorly documented. There seems to be support for using mmap to allocate memory from the OS, but AFAIK, the malloc version using this only supports Linux. By giving newlib the -DHAVE_MALLOC switch you can define your own malloc.

Has anybody tried to port Hoard, and especially with newlib? Is it easy to do, and does it require a lot of POSIX compliance?
User avatar
Owen
Member
Member
Posts: 1700
Joined: Fri Jun 13, 2008 3:21 pm
Location: Cambridge, United Kingdom
Contact:

Re: Using the Hoard memory allocator with newlib

Post by Owen »

Hoard is GPLv2 (or paid commercial license), which is probably problematic for most people here and therefore rarely used.

Commonly ported is dlmalloc, which is the "traditional standard" malloc. It's very easy to port, but the threading support is merely "thread safety", not any specialized thread support.

A good option is jemalloc, which is the FreeBSD libc's default allocator, plus used by Mozilla Firefox on Windows, Solaris and Linux. I have no experience porting JEMalloc, but the fact that it out of the box supports Linux + Win32 implies it has some form of portability layer.

Finally, as far as threads are concerned, newlib is a joke. It's multi-threaded support (particularly around the stdio layer) is conformant to no known standard.
Post Reply