Re: OSMalloc Fails (returns 0)
site_archiver@lists.apple.com Delivered-To: darwin-kernel@lists.apple.com -- Terry _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-kernel mailing list (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-kernel/site_archiver%40lists.a... On Dec 25, 2005, at 2:22 PM, Russ Seehafer wrote: I have a socket filter nke based on the tcplognke sample. I make a call to OSMalloc with the gOSMallocTag to malloc some space for a struct inside the nke's tl_attach_fn function. Usually this works great, but every now and then the malloc fails, usually after the system has been running for a while. Anyone know why this would happen? I couldn't find any documentation on it. In general, this shouldn't happen unless you are leaking memory (e.g. not freeing the memory on detach, attaching too many times, etc.). You can use the command "zprint" to display memory usage by zone on the system; I suspect you will see one of the kalloc.# zones that is the size of your structure (or larger, if your structure is not an even power of 2 in size) has hit its maximum number of elements. If you need a lot of memory and are willing to manage it yourself, you should alloc a page at a time; then you will also allocate pageable memory instead of wired memory (internally OSMalloc will call either kalloc() or kmem_alloc_pageable()). This email sent to site_archiver@lists.apple.com
participants (1)
-
Terry Lambert