AW: [En-Nut-Discussion] What stops a Nut... - Heap unavailable - suggestion

Don Ingram don at
Tue Jul 25 09:59:10 CEST 2006

Ernst Stippl wrote:
> Hi Don!
> One thing I found useful was to have thread looping doing printf (" avail:
> %x\n",  NutHeapAvailable ()); every 30 seconds (or whatever the right timing
> will be for you) this helped me narrowing down a mem leak which brought my
> system to an unexpected stop sometimes ....
> regard
> ernst 

Hi Ernst,  Thanks for the reply.

A suggestion to the group...

At present the debug version reports failed attempts at allocating heap space.

Is it possible ( in the standard build ) to define a global & have the heap
system increment this value when it has an allocation failure?

This would not directly point to the problem but it would show that it had
occurred at some stage. This covers the situations where malloc may be quietly
present in background code to which the apps programmer has no access. It also
provides a more direct indicator in case the heap avail values look sane but a
call requests an overly large amount.

Personally I try to avoid malloc like the plague on embedded systems, I much 
rather allocate fixed buffers for threads and work within them. No possibility 
of heap fragmentation at a later stage.



More information about the En-Nut-Discussion mailing list