Skip to main content
MStuc.1
Associate II
September 27, 2024
Question

Page size allocation for malloc

  • September 27, 2024
  • 2 replies
  • 1121 views

In the STM32CubeIDE predecessor (Atollic IDE) it was possible to set the page size allocation for malloc.

MStuc1_0-1727425781692.png

Is this somehow also possible in the STM32CubeIDE?

Is my understanding correct, that this page size will be reserved from the RAM by the sbrk() function. Then the malloc gets the needed size from this buffer. As soon as there is no longer enough space, the sbrk() functions gets another block?

Kind regards

Mathias

    2 replies

    Pavel A.
    Super User
    September 27, 2024

    In the C library that goes with CubeIDE you don't need it.

     

    MStuc.1
    MStuc.1Author
    Associate II
    September 27, 2024

    Thanks for the reply.

    But can I change it from 4096 bytes (default) to e.g. 128 bytes?

    Pavel A.
    Super User
    September 27, 2024

    Yes you can. But you don't need to, with the current version of newlib shipped with CubeIDE.

     

    MStuc.1
    MStuc.1Author
    Associate II
    October 1, 2024

    But if I would like to do it, how can I configure it?

    Pavel A.
    Super User
    October 1, 2024

    By modification of _sbrk (sysmem.c in your project) or by modification of malloc in newlib and rebuilding the newlib.