zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.2k stars 6.25k forks source link

Heap & Memory Allocation Statistics: add mallinfo support & better dynamic memory documentation #71069

Open htcrane opened 3 months ago

htcrane commented 3 months ago

Is your enhancement proposal related to a problem? Please describe. 1) The documentation does not make it obviously clear if using malloc() or k_malloc() is the preferred method for dynamic memory allocation. 2) There currently is no clean way of getting heap statistics for the standard library, such as with mallinfo().

Describe the solution you'd like 1) Provide the user with a standard library function to understand how much memory is left for allocation via malloc().

2) Provide clear documentation on why a user may want to use malloc() directly or stick to k_malloc().

3) Provide a memory summary documentation page. Looking through several issues, conversations about the heap talk about the heap available to the standard c libraries (malloc) and the system heap (k_alloc) interchangeably when they do not source their memory from the same heap.

Describe alternatives you've considered

Additional context

github-actions[bot] commented 3 months ago

Hi @htcrane! We appreciate you submitting your first issue for our open-source project. 🌟

Even though I'm a bot, I can assure you that the whole community is genuinely grateful for your time and effort. 🤖💙

htcrane commented 3 months ago

If my understanding is correct, I can open a PR to add the stubs and add some clearer documentation.