Re: malloc failure in a KEXT
Re: malloc failure in a KEXT
- Subject: Re: malloc failure in a KEXT
- From: Michael Smith <email@hidden>
- Date: Tue, 16 Jun 2009 14:57:47 -0700
On Jun 16, 2009, at 1:18 PM, Satyen Lele wrote: I am trying to debug a peculiar problem with malloc() failure inside a KEXT, when it is trying to allocate a struct of 9184 bytes size. malloc() returns ENOMEM after about 1139 such allocations – that’s just under 10MB. This problem is only reproducible on the two Mac Pros with 2GB RAM and Mac OS X 10.4.11. I panic’ed the system in the KEXT just after malloc returned error. Using zprint in gdb, I checked various memory zones and comparing the TOT_SZ and MAX_SZ, I can see 1 zone to be running out of space. However, if ELT_SZ is the allocation size of each element in the zone, it does not match the allocation that is failing. ZONE COUNT TOT_SZ MAX_SZ ELT_SZ ALLOC_SZ NAME 0x01f6ee40 2438 2bdfdc 2be000 44 1000 kernel map entries I have tried building the KEXT on a couple of Mac OS X and XCode combinations – 10.4.7+XCode2.5, 10.5.6+XCode3.1.2. How do I debug this problem?
Fix your design.
There's no good reason to perform a thousand separate allocations of that size; at the simplest level you should allocate a larger pool and manage your own allocations within it using an allocator that's tuned to your workload.
The kernel's base level address map has a limited number of entries allocated and it is not extensible; each of your allocations has consumed one of these entries, which is not a good use of the resource.
The size you quote is suspicious. You might want to look at more recent kernels and the way that memory is managed for jumbo frames. 8)
= Mike
-- The lyf so short, the craft so long to lerne -- Chaucer
|
_______________________________________________
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