Re: OSMalloc Fails (returns 0)
site_archiver@lists.apple.com Delivered-To: darwin-kernel@lists.apple.com Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:in-reply-to:references:mime-version:content-type:message-id:cc:content-transfer-encoding:from:subject:date:to:x-mailer:sender; b=VPOH9xD3fQ7xI/rQ03iQ47xIKhUnk2uQXba4wGm867L4NQBFgCFHvtc1f+KbUwBlLqjePzfObKqNdFOqpj/R0u2WSTeGJqGm2D+aJu/1dYaV6dgQkg0jftoBgrOQR9MTndYsW6W1kL30dwLC15X0T2kVgdD70GJFjhEJFtip6lc= On Jan 2, 2006, at 8:34 PM, Terry Lambert wrote: -Russ _______________________________________________ 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()). -- Terry OK, I have went through my mallocs and frees and I can't find any leaks. I did notice that the structure that causes the malloc to fail is bigger than I thought, a lot bigger. It is about 220000 bytes. Yes you read that right. What are my options for getting this much memory so frequently in the nke? Im not exactly clear on what you mean by getting memory a page at a time and managing it myself. Thanks so much for your input. This email sent to site_archiver@lists.apple.com
participants (1)
-
Russ Seehafer