[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
libobjc2, small objects, and custom allocation
From: |
Konstantin Osipov |
Subject: |
libobjc2, small objects, and custom allocation |
Date: |
Sat, 30 Jun 2012 00:24:47 +0400 |
Hello,
We use a custom memory allocator to allocate Objective C objects,
and it doesn't play well with libobjc2 small objects concept.
Here's how our code looks:
@implementation Request
+ (Request *) alloc
{
size_t sz = class_getInstanceSize(self);
id new = palloc(fiber->gc_pool, sz);
object_setClass(new, self);
return new;
}
Unfortunately, classForObject doesn't play along with an object
allocated this way, which leads to a crash in msg_send.
I figured (from the source) that object address got to be word-aligned to
ensure the runtime doesn't treat it as small object.
Is this correct? What are the chances of it breaking in the future?
What's the approach to memory allocation which ensures
custom-allocated objects are not mixed up with small objects?
Thanks,
--
http://tarantool.org - an efficient, extensible in-memory data store
- libobjc2, small objects, and custom allocation,
Konstantin Osipov <=