Date: Fri, 31 Oct 2003 18:46:26 +0100 From: Gerald Heinig <gheinig@syskonnect.de> To: hackers@freebsd.org Subject: kernel malloc usage Message-ID: <3FA29FF2.F0F3C009@syskonnect.de>
next in thread | raw e-mail | index | archive | help
Hi all, I have a question concerning the use of malloc to allocate small amounts of memory for packet wrappers for certain packets. Basically, I'm using malloc in much the same way as one would use it in a standard userland program: allocating small chunks and freeing them again a short(ish) time later. A colleague said this was a bad idea, since malloc should only really be used to allocate larger chunks (PAGE_SIZE and over) at driver initialisation. Management and partition of the allocated space should be done by the driver. His reason was that over time, the kernel heap memory gets progressively more fragmented until it becomes difficult to get larger blocks. Is this true? I seem to remember that FreeBSD has a slab allocator, which IIRC is particularly good at allocating small chunks. Is it a better idea to write my own allocators which use a larger block of memory allocated by malloc at driver start-time, or can I use malloc as in userland? Cheers, Gerald -- S y s K o n n e c t G m b H A Marvell Company Siemensstr. 23 D-76275 Ettlingen, Germany --------------------------------- Gerald Heinig Software Engineer ------------------------------------- phone: + 49 (0) 7243 502 354 fax: +49 (0) 7243 502 364 email: gheinig@syskonnect.de http://www.syskonnect.com
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3FA29FF2.F0F3C009>