next up previous contents
Next: Network System Up: The Fully Portable Subsystems Previous: File System: fs_romdisk   Contents

Memory Allocation System

KOS contains a full set of ANSI-standard memory allocation functions, implemented with the very popular dlmalloc library. This library is public domain and is very efficient for quickly allocating and freeing a large number of memory blocks, such as one might do from a C++ program.

The KOS kernel library also contains the GCC stub functions required for the use of the new and delete operators in C++. Thus you may write basic C++ programs without including any extra libraries to do so. In some cases, you may want to include libk++ as well, which is a very minimalistic stdc++ library for KOS. This avoids the necessity of building libstdc++ from GCC for about 99% of the cases.

Finally, if you feel comfortable with building your own KOS libraries and you are also comfortable with Makefiles, you may use the debug mallocator included with KOS. This is done by replacing ``malloc.o'' in kernel/mm/Makefile with malloc_debug.o and rebuilding. The debug mallocator never frees memory, so be aware of this if you use a lot of memory blocks. However, it does do buffer checking to look for overrun and underrun conditions, doubly freed blocks, leaked pointers, and other anomalies. If you enable the debug mallocator, you will also want to set INIT_MALLOCSTATS in your KOS_INIT_FLAGS line. This will tell the kernel to print out malloc stats when the program has exited since this is where all the extra checking is performed.


next up previous contents
Next: Network System Up: The Fully Portable Subsystems Previous: File System: fs_romdisk   Contents
Dan Potter 2002-07-29