RE: Memory allocation problem in kernel space.....
RE: Memory allocation problem in kernel space.....
- Subject: RE: Memory allocation problem in kernel space.....
- From: Matthew Xavier Mora <email@hidden>
- Date: Wed, 25 Apr 2007 10:16:31 -0700
Title: RE: Memory allocation problem in kernel
space.....
At 12:55 PM +0530 4/25/07, Gaurav Kumar wrote:
Hi Shawn,
When
I use IOMallocAligned the time for execution increases
200%.
For
eg :
A 10
gb disk takes 13 min to complete using new().
Same
disk when allocated using IOMalloc() takes 26 min
approx.
This
is the case when I replace medium and small memory allocation using
new() by IOMalloc.
If I
Use IOMallocPageable() or IOMallocAligned() for above case it works
fine i.e. time taken is same for new() and later
functions.
But
problem starts when I allocate Huge memory for my pointer using
IOMallocPageable() or IOMallocAligned().
Allocation does not fails but when my process uses it
after some time system crashes.
Sounds like you have a bug. Memory allocated
by new() in the kernel may be page aligned and have extra space
allocated to not allocate less than a page. So if you write or read
past the size you think you allocated you might still be
OK.
IOMallocAligned returns you the memory you
ask for so there is nothing allocated after your memory (there is
little or no slop) so if you walk of the end of your allocation, you
will crash.
Do not use new() or IOMalloc() for long term
memory use. Both of those use a small chunk of memory called the
kernel pool which is meant for fast and short allocations. There is a
limited amount of this precious resource. This pool is meant for
temporary allocations. Use IOMallocAligned() or better yet
IOBufferMemoryDescriptor for longer term storage.
<http://developer.apple.com/documentation/Darwin/Reference/KernelIOKitFramework/IOBufferMemoryDescriptor/Classes/IOBufferMemoryDescriptor/index.html>
Matt
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden