public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
* _reclaim_reent() and printf()
@ 2020-11-14 22:25 Rob Meades
  2020-11-14 23:12 ` Dave Nadler
  0 siblings, 1 reply; 2+ messages in thread
From: Rob Meades @ 2020-11-14 22:25 UTC (permalink / raw)
  To: newlib

I'm using an STM32F4 processor with newlib nano and FreeRTOS.  Have it all running quite sweetly, re-entrantly using the Dave Nadler code.  However, I find that the first call to printf() in a new task allocates 1468 bytes of memory and that memory is NOT reclaimed by the call to _reclaim_reent() that FreeRTOS makes on task deletion.

Has anyone seen a problem of this nature?  I note that at the end of _reclaim_reent() there's a comment:

/* Malloc memory not reclaimed; no good way to return memory anyway. */

Is this refering to memory malloc()ed by newlib, in which case why could it not be free'd()?  Or is my problem more likely to be something specific to ST's HAL (I haven't found anything yet, and would be surprised if a HAL malloc()ed memory)?

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: _reclaim_reent() and printf()
  2020-11-14 22:25 _reclaim_reent() and printf() Rob Meades
@ 2020-11-14 23:12 ` Dave Nadler
  0 siblings, 0 replies; 2+ messages in thread
From: Dave Nadler @ 2020-11-14 23:12 UTC (permalink / raw)
  To: Rob Meades, newlib

Whoops. Looks like a FreeRTOS bug (wrong assumption about newlib code).
I will try to look at this in detail tomorrow.
Because I never delete tasks I never noticed!

Thanks for pointing this out,
Best Regards, Dave

PS: The comment you referenced is only if normal reclamation did not happen,
which it doesn't if the FreeRTOS bug I think I see is real...

PPS: Can I hit you up with some uBlox questions sometime? ;-)

On 11/14/2020 5:25 PM, Rob Meades via Newlib wrote:
> I'm using an STM32F4 processor with newlib nano and FreeRTOS.  Have it all running quite sweetly, re-entrantly using the Dave Nadler code.  However, I find that the first call to printf() in a new task allocates 1468 bytes of memory and that memory is NOT reclaimed by the call to _reclaim_reent() that FreeRTOS makes on task deletion.
>
> Has anyone seen a problem of this nature?  I note that at the end of _reclaim_reent() there's a comment:
>
> /* Malloc memory not reclaimed; no good way to return memory anyway. */
>
> Is this refering to memory malloc()ed by newlib, in which case why could it not be free'd()?  Or is my problem more likely to be something specific to ST's HAL (I haven't found anything yet, and would be surprised if a HAL malloc()ed memory)?


-- 
Dave Nadler, USA East Coast voice (978) 263-0097, drn@nadler.com, Skype
  Dave.Nadler1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-11-14 23:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-14 22:25 _reclaim_reent() and printf() Rob Meades
2020-11-14 23:12 ` Dave Nadler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).