axis-c-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Susantha Kumara" <susan...@opensource.lk>
Subject RE: Memory Allocation - Issues
Date Thu, 29 Jul 2004 10:54:02 GMT
> -----Original Message-----
> From: Samisa Abeysinghe [mailto:samisa_abeysinghe@yahoo.com]
> Sent: Wednesday, July 28, 2004 4:34 PM
> To: Apache AXIS C Developers List
> Subject: RE: Memory Allocation - Issues
> 
> --- Susantha Kumara <susantha@opensource.lk> wrote:
> > Hi Shiraz,
> >
> > >       . AS C++ is and object oriented language and supports
concepts
> > like
> > > 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
> > allocation
> > > 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.
> 
> How much? Any measures?

Never measured. If you measure it the results depend on the array size /
OS / Available physical memory in your machine / layout of allocated and
free memory areas in heap etc.
Scenario is that initial array size is 2 and you keep doubling it until
you exceed your array size. 

> 
> Samisa...
> 
> >
> > >
> > > Hope this information is useful. Please feel free to send your
> > comments or
> > > suggestions regarding this issue.
> > >
> > > Thanks and regards,
> > >
> > > Shiraz.
> >
> > Susantha.
> >
> >
> 
> 
> 
> 
> __________________________________
> Do you Yahoo!?
> Yahoo! Mail is new and improved - Check it out!
> http://promotions.yahoo.com/new_mail


Mime
View raw message