I have a base class called ObjectBase which has a method killMe() which does some cleanup and then ‘delete this’. When I extend that class i’ve noticed I’m getting errors on the console
malloc: *** error for object 0x48fe84: Non-aligned pointer being freed
(I’m on osx and this error comes up when you try to delete memory not belonging to valid pointer).
I’ve noticed I get this when my subclass has multiple base classes, and ObjectBase is not first in the list. I’ve also noticed the address it gives in the error is not the address of the pointer but slightly offset. So then it occurred to me that maybe the ‘delete this’ in ObjectBase isn’t freeing the whole object but only the ObjectBase part of the object… is this the case? If so is there any way I can delete the whole object from its base class?