<?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>Nordic - nRF9160 (nRF Zephyr SDK) - Is __heapstats() Supported?  When will it be supported if not?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/92284/nordic---nrf9160-nrf-zephyr-sdk---is-__heapstats-supported-when-will-it-be-supported-if-not</link><description>Hello, 
 Are there plans to support the ARM function __heapstats() for the nRF9160 (under Zephyr)? 
 I see since 1.9.x sys_heap_runtime_stats_get() is supported - but when I try to compile under 1.9.1 it says I&amp;#39;m trying to redefine the function and/or</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 31 Mar 2023 04:48:17 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/92284/nordic---nrf9160-nrf-zephyr-sdk---is-__heapstats-supported-when-will-it-be-supported-if-not" /><item><title>RE: Nordic - nRF9160 (nRF Zephyr SDK) - Is __heapstats() Supported?  When will it be supported if not?</title><link>https://devzone.nordicsemi.com/thread/418463?ContentTypeID=1</link><pubDate>Fri, 31 Mar 2023 04:48:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:01ca44df-7c15-493c-a0c9-0e1f7c6a3a3c</guid><dc:creator>johnwest</dc:creator><description>&lt;p&gt;Hello Jaden,&lt;/p&gt;
&lt;p&gt;Thanks!&lt;br /&gt;John&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nordic - nRF9160 (nRF Zephyr SDK) - Is __heapstats() Supported?  When will it be supported if not?</title><link>https://devzone.nordicsemi.com/thread/418261?ContentTypeID=1</link><pubDate>Thu, 30 Mar 2023 10:12:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c4e80c18-27ea-4d83-ad1c-782cc1548e3f</guid><dc:creator>JadenUE</dc:creator><description>&lt;p&gt;Hi John,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Not sure if this is something of use to you but I will put it here for others facing this issue in the future.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I have had luck with the following:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;proj.conf:&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;CONFIG_SYS_HEAP_RUNTIME_STATS&lt;/span&gt;&lt;span&gt;=y&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;c function:&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;#include&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;&amp;lt;zephyr/sys/sys_heap.h&amp;gt;&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span&gt;// Debug Variables&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;extern&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;struct&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;k_heap&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;_system_heap&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;struct&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;sys_memory_stats&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;stats&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;void&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;rtos_hal_print_heap_info&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;void&lt;/span&gt;&lt;span&gt;)&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;sys_heap_runtime_stats_get&lt;/span&gt;&lt;span&gt;(&amp;amp;&lt;/span&gt;&lt;span&gt;_system_heap&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;heap&lt;/span&gt;&lt;span&gt;, &amp;amp;&lt;/span&gt;&lt;span&gt;stats&lt;/span&gt;&lt;span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;printk&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;\n&lt;/span&gt;&lt;span&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;printk&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&amp;quot;INFO: Allocated Heap = &lt;/span&gt;&lt;span&gt;%zu&lt;/span&gt;&lt;span&gt;\n&lt;/span&gt;&lt;span&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span&gt;stats&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;allocated_bytes&lt;/span&gt;&lt;span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;printk&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&amp;quot;INFO: Free Heap = &lt;/span&gt;&lt;span&gt;%zu&lt;/span&gt;&lt;span&gt;\n&lt;/span&gt;&lt;span&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span&gt;stats&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;free_bytes&lt;/span&gt;&lt;span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;printk&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&amp;quot;INFO: Max Allocated Heap = &lt;/span&gt;&lt;span&gt;%zu&lt;/span&gt;&lt;span&gt;\n&lt;/span&gt;&lt;span&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span&gt;stats&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;max_allocated_bytes&lt;/span&gt;&lt;span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;printk&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;\n&lt;/span&gt;&lt;span&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;return&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Kind Regards,&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Jaden&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nordic - nRF9160 (nRF Zephyr SDK) - Is __heapstats() Supported?  When will it be supported if not?</title><link>https://devzone.nordicsemi.com/thread/390538?ContentTypeID=1</link><pubDate>Thu, 13 Oct 2022 04:08:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:12371994-1e29-48a5-89bb-9eef2477bcb8</guid><dc:creator>johnwest</dc:creator><description>&lt;p&gt;Amanda,&lt;/p&gt;
&lt;p&gt;I see this in heap.c - I&amp;#39;ll focus on this:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;void *sys_heap_alloc(struct sys_heap *heap, size_t bytes)&lt;br /&gt;{&lt;br /&gt; struct z_heap *h = heap-&amp;gt;heap;&lt;/p&gt;
&lt;p&gt;if (bytes == 0U || size_too_big(h, bytes)) {&lt;br /&gt; return NULL;&lt;br /&gt; }&lt;/p&gt;
&lt;p&gt;chunksz_t chunk_sz = bytes_to_chunksz(h, bytes);&lt;br /&gt; chunkid_t c = alloc_chunk(h, chunk_sz);&lt;br /&gt; if (c == 0U) {&lt;br /&gt; return NULL;&lt;br /&gt; }&lt;/p&gt;
&lt;p&gt;/* Split off remainder if any */&lt;br /&gt; if (chunk_size(h, c) &amp;gt; chunk_sz) {&lt;br /&gt; split_chunks(h, c, c + chunk_sz);&lt;br /&gt; free_list_add(h, c + chunk_sz);&lt;br /&gt; }&lt;/p&gt;
&lt;p&gt;set_chunk_used(h, c, true);&lt;br /&gt;#ifdef CONFIG_SYS_HEAP_RUNTIME_STATS&lt;br /&gt; h-&amp;gt;allocated_bytes += chunksz_to_bytes(h, chunk_size(h, c));&lt;br /&gt;#endif&lt;br /&gt; return chunk_mem(h, c);&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;John&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nordic - nRF9160 (nRF Zephyr SDK) - Is __heapstats() Supported?  When will it be supported if not?</title><link>https://devzone.nordicsemi.com/thread/390530?ContentTypeID=1</link><pubDate>Thu, 13 Oct 2022 00:38:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:29745e10-60dd-4e6b-a4ce-633922f73491</guid><dc:creator>johnwest</dc:creator><description>&lt;p&gt;Amanda,&lt;/p&gt;
&lt;p&gt;At least that&amp;#39;s a real example that you&amp;#39;ve found -&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span class="pl-c1"&gt;sys_heap_runtime_stats_get&lt;/span&gt;&lt;span&gt;(&amp;amp;nrf_modem_lib_shmem_heap.&lt;/span&gt;&lt;span class="pl-smi"&gt;heap&lt;/span&gt;&lt;span&gt;, &amp;amp;stats-&amp;gt;&lt;/span&gt;&lt;span class="pl-smi"&gt;shmem&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span class="pl-smi"&gt;heap&lt;/span&gt;&lt;span&gt;);&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;And that&amp;#39;s great if it&amp;#39;s the nrf_model_lib_shmem_heap I&amp;#39;m wanting to monitor - but to be useful in this app I need a way to get a handle to the remaining available memory that&amp;#39;s in the 1/2 of the 9160&amp;#39;s M33 memory space - what&amp;#39;s left of the 0x40000 / 2 -&amp;gt; 0x20000 -&amp;gt; 128KB - what&amp;#39;s the handle to that?&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Once I know that - then sys_heap_runtime_stats_get() will be useful.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Maybe there&amp;#39;s an additional config option for this - I&amp;#39;ve searched &amp;#39;heap&amp;#39; in the available options - it doesn&amp;#39;t jump out at me if it&amp;#39;s there.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;If I&amp;#39;m understanding this correctly - there&amp;#39;s modem heap, Zephyr heap, and application heap - and I don&amp;#39;t know the handle to the application heap.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks,&lt;br /&gt;John&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nordic - nRF9160 (nRF Zephyr SDK) - Is __heapstats() Supported?  When will it be supported if not?</title><link>https://devzone.nordicsemi.com/thread/389867?ContentTypeID=1</link><pubDate>Fri, 07 Oct 2022 15:58:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0cf9dd84-9950-4a18-90d5-ef19a90765cf</guid><dc:creator>Amanda Hsieh</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Not sure what is your code, but you can take a look how it is used at&amp;nbsp;&lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/e54437a9feffa55f871e60559d7e495befeeb90a/lib/nrf_modem_lib/diag.c#L28"&gt;https://github.com/nrfconnect/sdk-nrf/blob/e54437a9feffa55f871e60559d7e495befeeb90a/lib/nrf_modem_lib/diag.c#L28&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Amanda&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nordic - nRF9160 (nRF Zephyr SDK) - Is __heapstats() Supported?  When will it be supported if not?</title><link>https://devzone.nordicsemi.com/thread/389719?ContentTypeID=1</link><pubDate>Thu, 06 Oct 2022 22:26:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:13c70afb-f6ac-4097-a95e-32e4b4988cba</guid><dc:creator>johnwest</dc:creator><description>&lt;p&gt;Amanda,&lt;/p&gt;
&lt;p&gt;That fixed the structure issue for&amp;nbsp;&lt;span&gt;struct sys_heap_runtime_stats stat;&amp;nbsp; -&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;but when I run the code it jumps to an exception.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I want to see if I can determine the real-time heap while running under Zephyr.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks,&lt;br /&gt;John W.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nordic - nRF9160 (nRF Zephyr SDK) - Is __heapstats() Supported?  When will it be supported if not?</title><link>https://devzone.nordicsemi.com/thread/388178?ContentTypeID=1</link><pubDate>Tue, 27 Sep 2022 14:13:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:be8b5196-36e7-431c-96fd-a12ae64201f0</guid><dc:creator>Amanda Hsieh</dc:creator><description>&lt;p&gt;Hi John,&lt;/p&gt;
[quote user=""]#define CONFIG_SYS_HEAP_RUNTIME_STATS[/quote]
&lt;p&gt;CONFIG_SYS_HEAP_RUNTIME_STATS should go in the prj.conf, not a source file.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Try to add it into&amp;nbsp;&lt;span&gt;the prj.conf and let me know it can work or not. Thanks.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Regards,&lt;br /&gt;Amanda&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nordic - nRF9160 (nRF Zephyr SDK) - Is __heapstats() Supported?  When will it be supported if not?</title><link>https://devzone.nordicsemi.com/thread/387990?ContentTypeID=1</link><pubDate>Mon, 26 Sep 2022 17:27:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:28504b41-bf4e-4547-8ac3-4d02b5387470</guid><dc:creator>johnwest</dc:creator><description>&lt;p&gt;Amanda,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;When I do that - it says sys_heap.h isn&amp;#39;t found.&lt;/p&gt;
&lt;p&gt;With&amp;nbsp;&lt;span&gt;#include &amp;lt;sys/sys_heap.h&amp;gt; - sys_heap.h is found.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Regards,&lt;br /&gt;John W.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nordic - nRF9160 (nRF Zephyr SDK) - Is __heapstats() Supported?  When will it be supported if not?</title><link>https://devzone.nordicsemi.com/thread/387974?ContentTypeID=1</link><pubDate>Mon, 26 Sep 2022 15:04:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:346f9b30-9f99-4209-84aa-c34b3c8bf866</guid><dc:creator>Amanda Hsieh</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
[quote user=""]#include &amp;lt;sys/sys_heap.h&amp;gt;[/quote]
&lt;p&gt;Can you try&amp;nbsp;&lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/e54437a9feffa55f871e60559d7e495befeeb90a/lib/nrf_modem_lib/diag.c#L3"&gt;&lt;span&gt;#&lt;/span&gt;&lt;span&gt;include&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;/a&gt;&lt;span&gt;&lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/e54437a9feffa55f871e60559d7e495befeeb90a/lib/nrf_modem_lib/diag.c#L3"&gt;&lt;span&gt;&amp;lt;&lt;/span&gt;zephyr/sys/sys_heap.h&lt;/a&gt;&lt;span&gt;&lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/e54437a9feffa55f871e60559d7e495befeeb90a/lib/nrf_modem_lib/diag.c#L3"&gt;&amp;gt;&lt;/a&gt;?&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Amanda&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>