<?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>CJSON failing to print via cJSON_Print()</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/99836/cjson-failing-to-print-via-cjson_print</link><description>I&amp;#39;m using the CJSON library to bundle up some log file data that I send over a custom BLE characteristic. Everything seems to work until I bump the number of data elements I am sending, and then I start getting errors back from my cJSON_Print ( ) API</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 25 May 2023 00:42:42 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/99836/cjson-failing-to-print-via-cjson_print" /><item><title>RE: CJSON failing to print via cJSON_Print()</title><link>https://devzone.nordicsemi.com/thread/427350?ContentTypeID=1</link><pubDate>Thu, 25 May 2023 00:42:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:95d4659c-c18e-46f7-b59a-9bca78b03503</guid><dc:creator>Mike Austin (LPI)</dc:creator><description>&lt;p&gt;Hi H&lt;span&gt;&amp;aring;&lt;/span&gt;kon,&lt;/p&gt;
&lt;p&gt;So, the cJSON_Init() issue was because I&amp;#39;d not added&amp;nbsp;CONFIG_HEAP_MEM_POOL_SIZE to my prj.conf file.&lt;/p&gt;
&lt;p&gt;And no - I hadn&amp;#39;t been calling cJSON_FreesString(). I&amp;#39;d only been calling&amp;nbsp;cJSON_Delete() once I&amp;#39;d completed creating the cJSON object and getting my char * to point to it.&amp;nbsp; I&amp;#39;d incorrectly assumed it was recycling the memory for the char *, but obviously that wasn&amp;#39;t the case and I was running into memory leak issues.&lt;/p&gt;
&lt;p&gt;Anyway, I&amp;#39;ve fixed the problem by allocating ~ 4kB of Heap memory and free-ing up the string after each time I&amp;#39;ve sent that string over BLE and I&amp;#39;m able to get 200+ log file elements sent across without&amp;nbsp;problems now.&lt;/p&gt;
&lt;p&gt;Thanks for helping me sort out my issue.&lt;/p&gt;
&lt;p&gt;Cheers,&lt;/p&gt;
&lt;p&gt;Mike&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CJSON failing to print via cJSON_Print()</title><link>https://devzone.nordicsemi.com/thread/426619?ContentTypeID=1</link><pubDate>Mon, 22 May 2023 14:06:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b796d2e4-0f71-402a-9a0d-f45fcafacac5</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;Are you calling &amp;quot;cJSON_FreeString()&amp;quot; when you&amp;#39;re done with the strings?&lt;/p&gt;
[quote user=""]I&amp;#39;ve read in a few posts the need to make a call to cJSON_Init() in my main, but the moment I add that, I get a compile error that says:[/quote]
&lt;p&gt;Are you including this?&lt;/p&gt;
&lt;p&gt;#include &amp;lt;zephyr/kernel.h&amp;gt;&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: CJSON failing to print via cJSON_Print()</title><link>https://devzone.nordicsemi.com/thread/426618?ContentTypeID=1</link><pubDate>Mon, 22 May 2023 14:06:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:115aa85a-8b8e-4fa2-bcc8-368efd11a662</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;Are you calling &amp;quot;cJSON_FreeString()&amp;quot; when you&amp;#39;re done with the strings?&lt;/p&gt;
[quote user=""]I&amp;#39;ve read in a few posts the need to make a call to cJSON_Init() in my main, but the moment I add that, I get a compile error that says:[/quote]
&lt;p&gt;Are you including this?&lt;/p&gt;
&lt;p&gt;#include &amp;lt;zephyr/kernel.h&amp;gt;&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: CJSON failing to print via cJSON_Print()</title><link>https://devzone.nordicsemi.com/thread/426384?ContentTypeID=1</link><pubDate>Fri, 19 May 2023 21:52:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7b587b44-9b5d-4f5b-8ed7-48d488f4b38c</guid><dc:creator>Mike Austin (LPI)</dc:creator><description>&lt;p&gt;Thanks for letting me know Edvin&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Mike&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CJSON failing to print via cJSON_Print()</title><link>https://devzone.nordicsemi.com/thread/426301?ContentTypeID=1</link><pubDate>Fri, 19 May 2023 12:15:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a07ca2c0-94d0-4191-8efc-fd889a885f5b</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;br /&gt;I am sorry, but we are short staffed this week due to Public Holidays in Norway. We will be back on Monday 22nd and hope to be able to answer all incoming requests within a couple of days, depending on the backlog. I am sorry for the inconvenience.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>