<?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>Memory leak with cJson library</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/80580/memory-leak-with-cjson-library</link><description>Hi everyone, 
 I&amp;#39;m collecting some data from the adxl362 accelerometer and from the env. sensor and sending them over MQTT. 
 This is the main.c file: 
 
 
 
 And this is the accel.c file where I get data from the accelerometer: 
 
 
 
 Everything works</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 14 Oct 2021 08:04:10 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/80580/memory-leak-with-cjson-library" /><item><title>RE: Memory leak with cJson library</title><link>https://devzone.nordicsemi.com/thread/334052?ContentTypeID=1</link><pubDate>Thu, 14 Oct 2021 08:04:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:833650c2-fd65-4be8-8494-9b79366187ff</guid><dc:creator>JONATHAN LL</dc:creator><description>&lt;p&gt;Hi,&lt;br /&gt;&lt;br /&gt;How does main.c have access to&amp;nbsp;moving_average_ variabele? The other cJSON data seems to be handled locale in the main.c file.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Maybe try to use extern on the moving_avrage variable.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Error handling on line 108-109, you don&amp;#39;t seem to check if it actually gets allocated.&lt;br /&gt;&lt;br /&gt;if (packet == NULL) {&lt;br /&gt;LOG_WRN(&amp;quot;Erorr, not enough memory!&amp;quot;);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Could you share the whole project?&lt;br /&gt;&lt;br /&gt;Can you debug&amp;nbsp;&lt;span&gt;moving_average_&lt;/span&gt;x, set a break point there, what is the actual value?&lt;br /&gt;&lt;br /&gt;Regards,&lt;br /&gt;Jonathan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Memory leak with cJson library</title><link>https://devzone.nordicsemi.com/thread/333985?ContentTypeID=1</link><pubDate>Wed, 13 Oct 2021 14:50:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:61ff4650-e956-437a-8e14-83f720b78fd1</guid><dc:creator>JONATHAN LL</dc:creator><description>&lt;p&gt;Hi Giuls,&lt;br /&gt;&lt;br /&gt;I will look in to this issue you have and come back with an update.&lt;br /&gt;Regards,&lt;br /&gt;Jonathan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>