Memory allocation

Hello folks,

         I have a code that need variables of 267kb. It is just one part of the functionality of the total code.I'm using softdevice s132 for ble. I'm using nrf_malloc to dynamically initialise arrays, i can't go beyond initialising more than 32bytes for each array. can anyone help me with the following. 

1) is this even possible?

2) from where can i get more memory on the device without any external memory

Please find the screenshot when i compile my code.

  • Hi

    1) The nRF52832 has got 64kB of RAM, so if you want to initialize 267kB (kiloBytes) of variables it won't work. If you only need 267kbits then it should be possible. 

    Have you checked if some of your variables are constant and could be put in the flash instead?

    The memory manager in the SDK is configured through the sdk_config.h file, and here you can choose how many blocks you need to assign, and how large they need to be. 
    The default configuration allows only a single small block, limited to 32 bytes, and zero medium or large sized blocks. You can change both the size and number of small/medium/large blocks to fit your requirements, but the memory consumption will increase the more you scale up. 

    2) The nRF52832 has 512kB of flash and 64kB of RAM, you can't get more. Either you have to pick a larger device such as the nRF52840, which has 1MB of flash and 256kB of RAM, or you have to find some way to optimize the RAM consumption of your application. 

    Best regards
    Torbjørn