So, what is your question? Have you written some sample code for us to look at?
In any case, heap management is what you are talking about, and there are a lot of techniques to properlyl manage it. How you do it in C vs C++ are very different, and different techniques can be used with different size objects in either to great effect. One of the big problems is heap fragmentation which happens when you do a lot of allocations and deallocations of small things, such as strings or small structures/classes. This can cause severe memory consumption over time for long running applications, such as servers.
for a usage example, look at "interface test.py".
the class in "magic" is actually updated to the new data type from within the interface.
I've tried my best to optimize as much as possible, but my best still isn't perfect, and I'm sure more can be done.
also note that this interface is still deep into development, so there's alot that's unfinshed.