Apple Developer Connection
Member Login Log In | Not a Member? Contact ADC

< Previous PageNext Page > Hide TOC

Allocating Memory in Tasks

In Mac OS X, if you need to allocate memory for a task, you can use malloc or the usual Core Foundation allocator functions, and free it using free or CFRelease respectively.

However, in Mac OS 9 and earlier, you must call the function MPAllocateAligned. Doing so returns a pointer to allocated memory with the alignment you specify. Prior to Mac OS X, you should always use the Multiprocessing Services memory allocation functions if your task needs to allocate, deallocate, or otherwise manipulate memory. For example, if your task deallocates its task data structure after it has finished processing, it must call MPFree. Note however, that since the memory is being deallocated by a preemptive task, you must have initially allocated the task record by calling MPAllocateAligned, even if this allocation didn’t occur in a preemptive task.



< Previous PageNext Page > Hide TOC


Last updated: 2007-10-31




Did this document help you?
Yes: Tell us what works for you.

It’s good, but: Report typos, inaccuracies, and so forth.

It wasn’t helpful: Tell us what would have helped.
Get information on Apple products.
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Copyright © 2007 Apple Inc.
All rights reserved. | Terms of use | Privacy Notice