<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>What is the minimum allowed/recommended value for CONFIG_HEAP_MEM_POOL_SIZE?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/114877/what-is-the-minimum-allowed-recommended-value-for-config_heap_mem_pool_size</link><description>Hi, 
 I am working on application code for the nrf9160. Current NCS version is 1.5.1, although I do not think my ancient NCS version is relevant to this issue. 
 I have removed all k_malloc statements (and calloc ) from my application code. I thought</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 23 Sep 2024 14:10:01 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/114877/what-is-the-minimum-allowed-recommended-value-for-config_heap_mem_pool_size" /><item><title>RE: What is the minimum allowed/recommended value for CONFIG_KERNEL_MEM_POOL_SIZE?</title><link>https://devzone.nordicsemi.com/thread/503427?ContentTypeID=1</link><pubDate>Mon, 23 Sep 2024 14:10:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:24537e79-03e3-4a61-9c21-4df2e0378b2f</guid><dc:creator>Fridtjof</dc:creator><description>&lt;p&gt;Hi Marte!&lt;/p&gt;
&lt;p&gt;Yes, I did mean &lt;code&gt;CONFIG_HEAP_MEM_POOL_SIZE&lt;/code&gt;&amp;nbsp;&lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f926.svg" title="Face palm"&gt;&amp;#x1f926;&lt;/span&gt;. I will edit the question to improve searchability.&lt;/p&gt;
&lt;p&gt;After doing some searching in the Zephyr documentation, it seems like the behavior of&amp;nbsp;&lt;span&gt;CONFIG_HEAP_MEM_POOL_SIZE&lt;/span&gt;&amp;nbsp;changed between Zephyr 2.7.5 and 3.6.0. I was reading the newer documentation, but am probably using the older Zephyr version (so my ancient NCS version was relevant after all). In newer Zephyr versions, it seems like Zephyr will set a higher heap size if submodules need it, even if the user sets &lt;span&gt;CONFIG_HEAP_MEM_POOL_SIZE=0&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;So if I only manage to upgrade I suppose this problem will solve itself.&lt;/p&gt;
&lt;p&gt;Thanks for the help!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: What is the minimum allowed/recommended value for CONFIG_KERNEL_MEM_POOL_SIZE?</title><link>https://devzone.nordicsemi.com/thread/503395?ContentTypeID=1</link><pubDate>Mon, 23 Sep 2024 12:33:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5e3cc437-aede-4bca-8076-5736a38c4cd4</guid><dc:creator>Marte Myrvold</dc:creator><description>&lt;p&gt;Hi Fridtjof,&lt;/p&gt;
&lt;p&gt;Do you mean CONFIG_HEAP_MEM_POOL_SIZE?&lt;/p&gt;
&lt;p&gt;Several components in an nRF9160 application might require dynamic memory allocation, even if your code does not explicitly call k_malloc, calloc, or similar functions.&lt;br /&gt;For instance, the modem library (nrf_modem_lib) requires a certain amount of heap memory to function correctly (configured by CONFIG_NRF_MODEM_LIB_HEAP_SIZE).&lt;br /&gt;Additionally, certain subsystems (boards, drivers, libraries, etc) might use dynamic memory allocation under the hood.&lt;/p&gt;
&lt;p&gt;If you set CONFIG_HEAP_MEM_POOL_SIZE=0, you instruct the kernel not to define the heap memory pool object. This could lead to errors if any part of your application or the underlying system services/libraries/drivers tries to allocate memory from the heap.&lt;/p&gt;
&lt;p&gt;You can see which subsystems are using dynamic memory allocation by looking at which files you get the undefined reference errors from, e.g.:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/home/marte/zephyr-sdk-0.16.5/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: modules/nrf/lib/lte_link_control/lib..__nrf__lib__lte_link_control.a(lte_lc_helpers.c.obj): in function `parse_ncellmeas_gci&amp;#39;:
/home/marte/ncs/nrf/lib/lte_link_control/lte_lc_helpers.c:1266: undefined reference to `k_calloc&amp;#39;
/home/marte/zephyr-sdk-0.16.5/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: modules/nrf/lib/nrf_modem_lib/lib..__nrf__lib__nrf_modem_lib.a(nrf91_sockets.c.obj): in function `nrf91_socket_offload_getaddrinfo&amp;#39;:
/home/marte/ncs/nrf/lib/nrf_modem_lib/nrf91_sockets.c:793: undefined reference to `k_malloc&amp;#39;
/home/marte/zephyr-sdk-0.16.5/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: modules/nrf/lib/nrf_modem_lib/lib..__nrf__lib__nrf_modem_lib.a(nrf91_sockets.c.obj): in function `nrf_to_z_addrinfo&amp;#39;:
/home/marte/ncs/nrf/lib/nrf_modem_lib/nrf91_sockets.c:314: undefined reference to `k_malloc&amp;#39;
/home/marte/zephyr-sdk-0.16.5/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: /home/marte/ncs/nrf/lib/nrf_modem_lib/nrf91_sockets.c:322: undefined reference to `k_malloc&amp;#39;
/home/marte/zephyr-sdk-0.16.5/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: modules/nrf/lib/at_cmd_parser/lib..__nrf__lib__at_cmd_parser.a(at_params.c.obj): in function `at_params_list_init&amp;#39;:
/home/marte/ncs/nrf/lib/at_cmd_parser/at_params.c:76: undefined reference to `k_calloc&amp;#39;
/home/marte/zephyr-sdk-0.16.5/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: modules/nrf/lib/at_cmd_parser/lib..__nrf__lib__at_cmd_parser.a(at_params.c.obj): in function `at_params_string_put&amp;#39;:
/home/marte/ncs/nrf/lib/at_cmd_parser/at_params.c:164: undefined reference to `k_malloc&amp;#39;
/home/marte/zephyr-sdk-0.16.5/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: modules/nrf/lib/at_cmd_parser/lib..__nrf__lib__at_cmd_parser.a(at_params.c.obj): in function `at_params_array_put&amp;#39;:
/home/marte/ncs/nrf/lib/at_cmd_parser/at_params.c:193: undefined reference to `k_malloc&amp;#39;
/home/marte/zephyr-sdk-0.16.5/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: modules/nrf/lib/lte_link_control/lib..__nrf__lib__lte_link_control.a(lte_lc.c.obj): in function `at_handler_ncellmeas_gci&amp;#39;:
/home/marte/ncs/nrf/lib/lte_link_control/lte_lc.c:369: undefined reference to `k_calloc&amp;#39;
/home/marte/zephyr-sdk-0.16.5/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: modules/nrf/lib/lte_link_control/lib..__nrf__lib__lte_link_control.a(lte_lc.c.obj): in function `at_handler_ncellmeas&amp;#39;:
/home/marte/ncs/nrf/lib/lte_link_control/lte_lc.c:427: undefined reference to `k_calloc&amp;#39;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Here, the lte_link_control, nrf_modem_lib, and at_cmd_parser dynamically allocate memory.&lt;/p&gt;
&lt;p&gt;However, if you do not explicitly allocate memory dynamically in your application, then it should be safe to configure it to be pretty low (or leave it undefined) as long as it is not 0, as, for example, the modem library defines its own heap size with CONFIG_NRF_MODEM_LIB_HEAP_SIZE. I would still strongly recommend testing your application to ensure that there are no unexpected behaviors due to the heap being too low.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Marte&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>