public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
From: Rob Meades <Rob.Meades@u-blox.com>
To: "newlib@sourceware.org" <newlib@sourceware.org>
Subject: Implementing a heap watermark
Date: Sun, 8 Nov 2020 17:14:05 +0000	[thread overview]
Message-ID: <sig.1581dd2f6c.CWXP265MB0039727CFB485A2881FCE9ADBEEB0@CWXP265MB0039.GBRP265.PROD.OUTLOOK.COM> (raw)

I run/test my library code on various embedded processors (STM32F4, NRF52/53, ESP32), all of which use newlib.

I need to implement a "minimum heap ever available" watermark kind of function so that, after my tests are run, I can be sure that I have left sufficient room for user code to obtain heap memory.

Such a facility does not seem to be available in newlib out of the box: does anyone have any recommendations on how to go about implementing such a function?

For instance, is the newlib malloc()ater guaranteed to only call sbrk() when it really needs more memory, as opposed to when it might have free blocks available but it is "cheaper" to call sbrk() then to allocate from those blocks?  If the former then simply monitoring sbrk() would do the job for me.  If the latter then I probably have to intercept the malloc()/free() calls to track what's going on.

Rob


             reply	other threads:[~2020-11-08 17:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-08 17:14 Rob Meades [this message]
2020-11-09 14:08 ` Federico Terraneo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sig.1581dd2f6c.CWXP265MB0039727CFB485A2881FCE9ADBEEB0@CWXP265MB0039.GBRP265.PROD.OUTLOOK.COM \
    --to=rob.meades@u-blox.com \
    --cc=newlib@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).