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?
Using the Hoard memory allocator with newlib
- Owen
- Member
- Posts: 1700
- Joined: Fri Jun 13, 2008 3:21 pm
- Location: Cambridge, United Kingdom
- Contact:
Re: Using the Hoard memory allocator with newlib
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.
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.