Dynamic memory allocation approaches for C++ apps - pros and cons
Angelo Fraietta
newsgroups at smartcontroller.com.au
Tue Dec 4 20:58:27 UTC 2007
Robert S. Grimes wrote:
> Angelo Fraietta wrote:
>
>>Robert S. Grimes wrote:
>>
>>
>>>Might I ask what you based your allocator on? Did you use a chunk of
>>>memory from the heap, and manage that yourself? Or did you use RTEMS
>>>Regions or Partitions? I'm particularly interested in the "quality" of
>>>those subsystems.
>>>
>>>
>>
>>I created a linked list for each class and allocated will malloc when i
>>needed it - the size of the required memory is passed in operator new of
>>the class. Instead of freeing the memory when I released in my app via
>>'delete' , I put it aside and cached for use in the next allocation via
>>'new'
>>
>>
> Thanks for the reply. So you just used malloc to get the memory, and
> kept it for yourself. Sounds clean and simple, and I would guess if a
> single task was using it, a great approach.
I use it in multi tasking, but I use a semaphore to gain exclusive access.
--
Dr Angelo Fraietta
A.Eng, A.Mus.A, BA(Hons), Ph.D.
PO Box 859
Hamilton NSW 2303
Home Page
http://www.smartcontroller.com.au/
There are those who seek knowledge for the sake of knowledge - that is
CURIOSITY
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)
More information about the users
mailing list