Re: OSMalloc Fails (returns 0)
Re: OSMalloc Fails (returns 0)
- Subject: Re: OSMalloc Fails (returns 0)
- From: Terry Lambert <email@hidden>
- Date: Mon, 2 Jan 2006 17:34:52 -0800
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()).
-- Terry
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden