axis-c-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Susantha Kumara" <>
Subject RE: Memory Allocation - Issues
Date Wed, 28 Jul 2004 04:29:54 GMT
Hi Shiraz,

>       . AS C++ is and object oriented language and supports concepts
> destructors and constructors the C programming language not being
> object oriented does not support them. Therefore when we de-allocate
> memory allocated by C++ code using C style "free" memory
> de-allocation mechanism the destructors are not called.
> The solution for the above problem might be to completely change the
> memory allocation mechanism to C++ style memory allocation mechanism.
> However there seems to be issues when we try to go for this solution.

Our aim is to use one memory allocation mechanism. So inside the Axis
Engine we have classes with constructors and destructors (some times
virtual destructors). So we need to use new/delete mechanism anyway. So
the good idea to use the same new/delete mechanism to allocate user
types as well.

>       . When an array is de-serialized it uses C style memory
> mechanism in the present code and needs a memory "re-allocation"
> mechanism for this purpose, C++ does not support "realloc" and if we
> use "new" instead we have to allocate fresh memory blocks each time
> we need to increase the array size. This can be more expensive than
> using "realloc".

Even if using "new/memcpy/delete" instead of "realloc" might affect
performance. We have no choice.

> Hope this information is useful. Please feel free to send your
comments or
> suggestions regarding this issue.
> Thanks and regards,
> Shiraz.


View raw message