mallinfo arena and uordblks unintialized?
Grant Edwards <[email protected]> Tue, 17 Feb 2026 04:29:11 -0000 (UTC)
| Newsgroups | gmane.comp.lib.newlib |
|---|---|
| Message-ID | <[email protected]> |
I'm working with newlib 3.3.0 on an ARM Cortex-M3. It was distributed
as part of ARM Inc GNU Arm Embedded Toolchain version 2020-q2-update.
I've implmented _sbrk_r() and have been testing malloc(). It's
calling _sbrk_r() as expected. I can see that _sbrk_r() runs out of
memory and malloc() fails after I've allocated the "expected" max
amount of memory.
What's odd are the values returned by mallinfo().
The initial values of arena and uordblks are a large, apparently
random number. For example, before the first malloc() call:
arena=4695456 ordblks=0, uordblks=4695456, fordblks=0
Each time _sbrk_r() is called, arena increases by the sbrk increment,
and uordblks increases by (increment - malloc_size - 8). [Where the
malloc_size is the size of the malloc request that triggered the call
to _sbrk_r()].
Why do arena and uardblks start out at a large random value before any
malloc calls are made? Is that something I can just ignore?
Is there something I need to call to initizize malloc's internal data
structures?
I've tried changing the "userspace" mallinfo struct fields from
size_t to int, and it had no effect. It's a 32-bit target, and size_t
is the same size as int.
--
Grant