<?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>Frequent NVS Writes</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/119639/frequent-nvs-writes</link><description>Hello, 
 I&amp;#39;m working up an application where tens of kilobytes are sent via bluetooth to a device which then stores the data on the internal flash (nrf52832). I&amp;#39;ve worked on defining a larger section of memory for the flash and the data is sent over in</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 10 Mar 2025 15:25:42 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/119639/frequent-nvs-writes" /><item><title>RE: Frequent NVS Writes</title><link>https://devzone.nordicsemi.com/thread/526608?ContentTypeID=1</link><pubDate>Mon, 10 Mar 2025 15:25:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4b434ae3-b1c1-479f-8bd5-e3412340eae1</guid><dc:creator>Neil Benn</dc:creator><description>&lt;p&gt;That was the exact issue- thanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Frequent NVS Writes</title><link>https://devzone.nordicsemi.com/thread/526607?ContentTypeID=1</link><pubDate>Mon, 10 Mar 2025 15:24:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:25fb7380-c19f-4c2d-862a-e973a86ceef0</guid><dc:creator>Neil Benn</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;&amp;nbsp; Yes - it actually wasn&amp;#39;t in that place where there was an error but another method had a memory leak.&amp;nbsp; I&amp;#39;m about to try this wit the data coming from the BLE stack.&amp;nbsp; However if that is giving me a problem its a different issue so I&amp;#39;ll close this ticket and thanks.&lt;/p&gt;
&lt;p&gt;Cheers,&lt;/p&gt;
&lt;p&gt;Neil&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Frequent NVS Writes</title><link>https://devzone.nordicsemi.com/thread/526605?ContentTypeID=1</link><pubDate>Mon, 10 Mar 2025 15:21:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b3d10a40-71dc-4bef-a0fa-3a93160dc8a4</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Is the function&amp;nbsp;store_slice_bw() also calling k_malloc()?&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;for (int i = 0; i &amp;lt; 10; i++){
    delete_slice(i + 1);
    store_slice_bw(cds, true);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;if it is based on the original &amp;quot;store_slice&amp;quot; function, it seems to allocate cds.len+4 bytes within a for-loop, draining the HEAP.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Frequent NVS Writes</title><link>https://devzone.nordicsemi.com/thread/526603?ContentTypeID=1</link><pubDate>Mon, 10 Mar 2025 15:15:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4b54e1e2-cc8c-4057-b258-8ef247c4dfcb</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi Neil,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Were you able to get past the second iteration after free&amp;#39;ing the data?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Frequent NVS Writes</title><link>https://devzone.nordicsemi.com/thread/526590?ContentTypeID=1</link><pubDate>Mon, 10 Mar 2025 14:53:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7d7ad937-e619-4b3a-a8b5-cfe954256f8a</guid><dc:creator>Neil Benn</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp; Good point on the memory freeing thanks - though this is just a test case and I&amp;#39;ll throw the code away once I can work out how to store larger entries; on the memory I&amp;#39;ve got:&lt;/p&gt;
&lt;p&gt;&lt;span&gt;CONFIG_HEAP_MEM_POOL_SIZE&lt;/span&gt;&lt;span&gt;=4026&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE&lt;/span&gt;&lt;span&gt;=9048&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; I increased the stack size because in the real use case I&amp;#39;ll be taking data in from a BLE callback.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Cheers,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Neil&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Frequent NVS Writes</title><link>https://devzone.nordicsemi.com/thread/526581?ContentTypeID=1</link><pubDate>Mon, 10 Mar 2025 14:19:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8a897861-69a7-43c1-a2e2-f69dfcf2d97b</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I see that you are allocating memory, but there&amp;#39;s no free-call? Where do you call k_free()?&lt;/p&gt;
&lt;p&gt;You do not check the return ptr from malloc, which I strongly recommend that you do.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;What is the configured system heap size, ie. CONFIG_HEAP_MEM_POOL_SIZE?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Frequent NVS Writes</title><link>https://devzone.nordicsemi.com/thread/526406?ContentTypeID=1</link><pubDate>Fri, 07 Mar 2025 17:04:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a3445fcc-b63f-45cc-8643-07b6a39b8f40</guid><dc:creator>Neil Benn</dc:creator><description>&lt;p&gt;I put some code in to check the sector space and increased the size of each sector but that is not the cause,&amp;nbsp;it still fails, interestingly all write under ~400 bytes work with everything over 550 bytes failing and intermittent failures between those two levels.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>