[chbot] Heaps and heaps of storage

Richard Jones rjtp at ihug.co.nz
Tue Jul 2 10:05:33 BST 2013


Nice to cook this old chestnut again :-)

Over the years I've gone to great lengths to share tiny memory resources
around big projects in deterministic ways. I'm happy to whiteboard at least
3 I invented that are no doubt buried in books of patterns at our next
meeting. As memory has become more ubiquitous the pendulum swings the other
way and the early use of C++/STL yields huge gains in productivity. Then we
may end up spending more time removing the hidden news and deletes down the
track.

You can't un-invent these things and I don't subscribe to malloc or new
being bad. Memory allocation and re-allocation are just a nice sharp tools
to be used where appropriate.

http://en.wikipedia.org/wiki/Standard_Template_Library is a nice short read.

Richard

On Tue, Jul 2, 2013 at 10:54 AM, Charles Manning <cdhmanning at gmail.com>wrote:

> As a general principle, I share your disdain of malloc and cronies in
> embedded.
>
> These functions are not at all predictable in their performance and
> reliability. With time, vast amounts of malloc/free can cause memory
> fragmentation which can, in turn, cause all sorts of "interesting"
> behaviours. This is particularly true of the simplistic memory allocators
> used in many embedded systems.
>
> IMHO, well not so humble opinion, it is safe to use malloc etc to allocate
> storage which is then managed by a code body as a "pool" or resources for
> that code body. This does not cause memory fragmentation and reduces the
> number of malloc calls by a buge amount.
>
> For example, consider some code to handle a network protocol. Buffers
> could be
> created and released on the fly with malloc()/free(), or you could
> allocate a
> pool of buffers and then get then from the buffer or release them back to
> the
> buffer when done.
>
>
>
>
> On Tuesday 02 July 2013 10:38:46 Mark Atherton wrote:
> > <
> http://www.embedded.com/design/programming-languages-and-tools/4416457/EMB
> >-tm-6-15-13-Dynamic-memory-and-heap-contiguity>
> http://www.embedded.com/desig
>
> >n/programming-languages-and-tools/4416457/EMB-tm-6-15-13-Dynamic-memory-and-
> >heap-contiguity
> >
> >
> > a while ago, someone at the group looked at me sideways when I
> > expressed my disdain about the use of heaps, malloc(), free() etc. in
> > an embedded environment.
> >
> > this article covers some of the issues, along with some new ideas.
> >
> > -Mark
> >
> >
> >
> > _______________________________________________
> > Chchrobotics mailing list Chchrobotics at lists.linuxnut.co.nz
> > http://lists.ourshack.com/mailman/listinfo/chchrobotics
> > Mail Archives: http://lists.ourshack.com/pipermail/chchrobotics/
> > Web site: http://kiwibots.org
> > Meetings 3rd Monday each month at Tait Radio Communications, 175 Roydvale
> > Ave, 6.30pm
> >
> > When replying, please edit your Subject line to reflect new content.
>
>
>
> _______________________________________________
> Chchrobotics mailing list Chchrobotics at lists.linuxnut.co.nz
> http://lists.ourshack.com/mailman/listinfo/chchrobotics
> Mail Archives: http://lists.ourshack.com/pipermail/chchrobotics/
> Web site: http://kiwibots.org
> Meetings 3rd Monday each month at Tait Radio Communications, 175 Roydvale
> Ave, 6.30pm
>
> When replying, please edit your Subject line to reflect new content.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ourshack.com/pipermail/chchrobotics/attachments/20130702/e1b30ec6/attachment.html>


More information about the Chchrobotics mailing list