<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[At what time should I manually run gc.collect()?]]></title><description><![CDATA[<p dir="auto">Should I setup a background thread to just run it every few hundred milliseconds? Is that what the automatic collector does?<br />
Is that reliable?<br />
<a href="https://docs.pycom.io/pycom_esp32/library/gc.html" target="_blank" rel="noopener noreferrer nofollow">https://docs.pycom.io/pycom_esp32/library/gc.html</a></p>
]]></description><link>https://forum.pycom.io/topic/1454/at-what-time-should-i-manually-run-gc-collect</link><generator>RSS for Node</generator><lastBuildDate>Sat, 13 Jun 2026 02:39:36 GMT</lastBuildDate><atom:link href="https://forum.pycom.io/topic/1454.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 05 Jul 2017 03:26:53 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to At what time should I manually run gc.collect()? on Wed, 05 Jul 2017 15:34:06 GMT]]></title><description><![CDATA[<p dir="auto">Should I setup a background thread to just run it every few hundred milliseconds? Is that what the automatic collector does?<br />
Is that reliable?<br />
<a href="https://docs.pycom.io/pycom_esp32/library/gc.html" target="_blank" rel="noopener noreferrer nofollow">https://docs.pycom.io/pycom_esp32/library/gc.html</a></p>
]]></description><link>https://forum.pycom.io/post/9124</link><guid isPermaLink="true">https://forum.pycom.io/post/9124</guid><dc:creator><![CDATA[BetterAuto]]></dc:creator><pubDate>Wed, 05 Jul 2017 15:34:06 GMT</pubDate></item><item><title><![CDATA[Reply to At what time should I manually run gc.collect()? on Wed, 05 Jul 2017 06:26:07 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.pycom.io/uid/919">@BetterAuto</a><br />
There is not good answer to this question.<br />
As always it depends.</p>
<p dir="auto">But if you have infinite &quot;main&quot; loop<br />
then it is good practice if you put <code>gc.collect()</code> at least once.<br />
I say depends, because if you have some intensive memory operation<br />
you probably need to run it more the times.</p>
<p dir="auto">You can also monitor <code>gc.mem_free()</code> and after mem go to some level run <code>gc.collect()</code>.</p>
<p dir="auto">You also can go in oposite direction and do not run it at all. It &quot;should&quot; be run automatically but then it can run in your time critical point and brake your logic.</p>
]]></description><link>https://forum.pycom.io/post/9127</link><guid isPermaLink="true">https://forum.pycom.io/post/9127</guid><dc:creator><![CDATA[livius]]></dc:creator><pubDate>Wed, 05 Jul 2017 06:26:07 GMT</pubDate></item><item><title><![CDATA[Reply to At what time should I manually run gc.collect()? on Wed, 05 Jul 2017 15:32:38 GMT]]></title><description><![CDATA[<p dir="auto">Any reason not to just have it running in the background every few hundred milliseconds? It can check mem_free and auto-run. I can fork off a new thread and have it constantly run. Is that what the automatic collector does?</p>
]]></description><link>https://forum.pycom.io/post/9140</link><guid isPermaLink="true">https://forum.pycom.io/post/9140</guid><dc:creator><![CDATA[BetterAuto]]></dc:creator><pubDate>Wed, 05 Jul 2017 15:32:38 GMT</pubDate></item><item><title><![CDATA[Reply to At what time should I manually run gc.collect()? on Wed, 05 Jul 2017 18:54:49 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.pycom.io/uid/919">@BetterAuto</a></p>
<blockquote>
<p dir="auto">Any reason not to just have it running in the background every few hundred milliseconds?</p>
</blockquote>
<p dir="auto">then it can run in your time critical point and brake your logic...<br />
better have control when and where in the code it run.</p>
]]></description><link>https://forum.pycom.io/post/9148</link><guid isPermaLink="true">https://forum.pycom.io/post/9148</guid><dc:creator><![CDATA[livius]]></dc:creator><pubDate>Wed, 05 Jul 2017 18:54:49 GMT</pubDate></item><item><title><![CDATA[Reply to At what time should I manually run gc.collect()? on Thu, 06 Jul 2017 19:39:48 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.pycom.io/uid/919">@BetterAuto</a> In one project I shut off automatic garbage collection and then called collect after each loop of measuring time with an ultrasound distance detector, to secure (as well as possible) that the timing wouldn't go wonky.</p>
]]></description><link>https://forum.pycom.io/post/9162</link><guid isPermaLink="true">https://forum.pycom.io/post/9162</guid><dc:creator><![CDATA[papasmurph]]></dc:creator><pubDate>Thu, 06 Jul 2017 19:39:48 GMT</pubDate></item><item><title><![CDATA[Reply to At what time should I manually run gc.collect()? on Fri, 07 Jul 2017 02:06:51 GMT]]></title><description><![CDATA[<p dir="auto">So it sounds like one risk is latency. What other risks are there from running it?</p>
]]></description><link>https://forum.pycom.io/post/9165</link><guid isPermaLink="true">https://forum.pycom.io/post/9165</guid><dc:creator><![CDATA[BetterAuto]]></dc:creator><pubDate>Fri, 07 Jul 2017 02:06:51 GMT</pubDate></item></channel></rss>