Skip to main content
MStuc.1
Associate II
Question

Page size allocation for malloc

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

    This topic has been closed for replies.

    5 replies

    Pavel A.

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

     

    MStuc.1
    MStuc.1Author
    Associate II

    Thanks for the reply.

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

    Pavel A.

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

     

    MStuc.1
    MStuc.1Author
    Associate II

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

    Pavel A.

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