-
Notifications
You must be signed in to change notification settings - Fork 8
Allocators used by the runtime
Nat! edited this page Sep 9, 2018
·
2 revisions
All memory location is done using mulle-allocator. There are various allocators used:
Allocator | Accessor | Description |
---|---|---|
Universe | _mulle_objc_universe_get_allocator |
Used to construct classes, methodlists etc. |
Foundation | _mulle_objc_universe_get_foundation_allocator |
The default allocator to be placed into infraclasses |
Infraclass | _mulle_objc_infraclass_get_allocator |
The allocator to use for instance memory |
How do you move a class with its relations to a shared memory page, to make it shareable with other processes ?
Here are the various problems. isa needs to be compatible across the runtimes. This can be accomplished by forking both processes off the same common process. If you have a class Foo with a custom allocator and it has an ivar of type NSString, the NSString must be have the same custom allocator, so it is placed in the same memory region.
If you have a NSArray you don't copyWithZone: the elements, you retain them. But you have no control, about the NSZone those elements are in. So you have a container in one zone and elements in another, which could be bad. That's the same with allocators, but that's the reason NSZone is not exposed as concept anymore.
- use a reference to a static allocator
- in
+initialize
of your class set the allocator with_mulle_objc_infraclass_set_allocator( self, &my_allocator)
- in your accessors make sure, that incoming values have been made with a compatible allocator