[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Dynamic memory allocation approaches for C++ apps - pros and cons
- Date: Sun, 02 Dec 2007 11:38:46 +1100
- From: newsgroups at smartcontroller.com.au (Angelo Fraietta)
- Subject: Dynamic memory allocation approaches for C++ apps - pros and cons
Robert S. Grimes wrote:
> I'm just looking for some advice and pointers here - no specific
> problems (yet!)...
> What are the relative pros and cons of the various available dynamic
> memory allocation approaches in modern RTEMS applications? One choice
> is the C++ operators new/delete, which presumably call malloc and free
> under the covers. What are the characteristics wrt determinism,
> fragmentation, etc.?
It depends on what your requirements are.
I had to develop a per class allocator due to the number of allocations
and deallocations I was making. I found that using the heap, my app
froze after about 2 days running (it was doing 100 allocations and
deallocations per second) due to memory fragmentation.
After implementing my allocator for each class, through overloading
operators new and delete in each class, my app ran two weeks without
incident with the same number of allocations and deallocations.
Dr Angelo Fraietta
A.Eng, A.Mus.A, BA(Hons), Ph.D.
PO Box 859
Hamilton NSW 2303
There are those who seek knowledge for the sake of knowledge - that is
There are those who seek knowledge to be known by others - that is VANITY
There are those who seek knowledge in order to serve - that is LOVE
Bernard of Clairvaux (1090 - 1153)