Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Dynamically growable/shrinkable block of RAM?



On Nov 2, 2003, at 4:43 AM, Theodore H. Smith wrote:

In essence, my question is: "Whats the most efficient way to dynamically shrink and grow a block of allocated RAM, using the least copy actions possible, while also allowing the area of RAM in shrunk blocks to be reused by other code".


The answer, on Mac OS X is vm_allocate/vm_deallocate.

So, right now, I'm using malloc/realloc, which in turn on OSX, is a wrapper to NewPtr and BlockMoveData. This wrapping is done by CodeWarrior's libraries (which of course the source to is included!)

So, thats MW ANSI malloc -> Carbon NewPtr -> Mach malloc -> Mach vm_allocate.

I would not recommend writing your own malloc replacement on top of vm_allocate; the Mach malloc is performs quite well. But if you have a special need for a super-high-performance page allocator, vm_allocate might be the way to go.

http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/vm_allocate.html

--smz
_______________________________________________
carbon-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/carbon-development
Do not post admin requests to the list. They will be ignored.

References: 
 >Dynamically growable/shrinkable block of RAM? (From: "Theodore H. Smith" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.