Memory allocation

Hi

I'm trying to figure out how to manage my memory on the nrf9160 sip. Currently my application crashes on a specific lines where I try to allocate a large C++ string (the crash happens at around a string size of 10 kB see call stack below).  

I've tried playing around with the config file and use different sizes, but nothing seems to help.

# Heap and stacks
CONFIG_HEAP_MEM_POOL_SIZE=32000
CONFIG_MAIN_STACK_SIZE=32000
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=32000

I can see when I'm building my application I get this memory report, which also indicates that I lots of unused memory:

I also found the thread analyzer function to print out the stack usage of all threads, which reports runtime that there is lots of memory left:

[00:04:20.621,856] <inf> thread_analyzer: Thread analyze:
[00:04:20.622,406] <inf> thread_analyzer:  0x20011310          : STACK: unused 496 usage 272 / 768 (35 %); CPU: 0 %
[00:04:20.623,046] <inf> thread_analyzer:       : Total CPU cycles used: 51217
[00:04:20.623,718] <inf> thread_analyzer:  0x200113b8          : STACK: unused 848 usage 176 / 1024 (17 %); CPU: 0 %
[00:04:20.624,389] <inf> thread_analyzer:       : Total CPU cycles used: 1
[00:04:20.628,845] <inf> thread_analyzer:  0x20011660          : STACK: unused 31368 usage 752 / 32120 (2 %); CPU: 0 %
[00:04:20.629,547] <inf> thread_analyzer:       : Total CPU cycles used: 1188
[00:04:20.630,126] <inf> thread_analyzer:  0x200114b0          : STACK: unused 236 usage 84 / 320 (26 %); CPU: 58 %
[00:04:20.630,767] <inf> thread_analyzer:       : Total CPU cycles used: 4950365
[00:04:20.634,155] <inf> thread_analyzer:  0x20011558          : STACK: unused 22480 usage 9640 / 32120 (30 %); CPU: 41 %
[00:04:20.634,857] <inf> thread_analyzer:       : Total CPU cycles used: 3513906
[00:04:20.635,559] <inf> thread_analyzer:  ISR0                : STACK: unused 1672 usage 376 / 2048 (18 %)

I do not use dynamic allocation (or atleast not that I'm aware of) so the heap should be unsed.

Is this a memory issue? And is there any way to get more information about my memory usage runtime?

Parents Reply Children
No Data
Related