<?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[Force a global reset]]></title><description><![CDATA[<p>Is there a way to force a global reset from within the game loop with the iVM architecture?</p>
<p>I tried changing the name of module.exports.loop to module.exports.foo, hoping that would force me back into the pre-loop execution-style for a tick, but it didn't work.</p>
]]></description><link>http://screeps.com/forum/topic/2185/force-a-global-reset</link><generator>RSS for Node</generator><lastBuildDate>Sun, 17 May 2026 17:40:01 GMT</lastBuildDate><atom:link href="http://screeps.com/forum/topic/2185.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 07 Apr 2018 19:56:23 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Force a global reset on Invalid Date]]></title><description><![CDATA[<p>Is there a way to force a global reset from within the game loop with the iVM architecture?</p>
<p>I tried changing the name of module.exports.loop to module.exports.foo, hoping that would force me back into the pre-loop execution-style for a tick, but it didn't work.</p>
]]></description><link>http://screeps.com/forum/post/10131</link><guid isPermaLink="true">http://screeps.com/forum/post/10131</guid><dc:creator><![CDATA[black0441]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Force a global reset on Invalid Date]]></title><description><![CDATA[<p>I would like this functionality as well, as I can think of a number of cases where it would be useful.</p>
]]></description><link>http://screeps.com/forum/post/10159</link><guid isPermaLink="true">http://screeps.com/forum/post/10159</guid><dc:creator><![CDATA[tedivm]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Force a global reset on Invalid Date]]></title><description><![CDATA[<p>If I remember correctly, you can do a partial reset by calling <code>global.requireCache = {};</code> which will cause all of your modules to get reloaded. This doesn't explicitly  reload anything you placed directly in <code>global</code>, but it was good enough for my use-case.</p>
]]></description><link>http://screeps.com/forum/post/10161</link><guid isPermaLink="true">http://screeps.com/forum/post/10161</guid><dc:creator><![CDATA[Gankdalf]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Force a global reset on Invalid Date]]></title><description><![CDATA[<p>infinite loop crunching random numbers ftw...</p>
]]></description><link>http://screeps.com/forum/post/10165</link><guid isPermaLink="true">http://screeps.com/forum/post/10165</guid><dc:creator><![CDATA[MrFaul]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Force a global reset on Invalid Date]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="http://screeps.com/forum/uid/85">@mrfaul</a> timing out actually doesn't reset the global</p>
]]></description><link>http://screeps.com/forum/post/10166</link><guid isPermaLink="true">http://screeps.com/forum/post/10166</guid><dc:creator><![CDATA[Gankdalf]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Force a global reset on Invalid Date]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="http://screeps.com/forum/uid/252">@gankdalf</a> Thanks, I'll try that. I think I have a memory leak in a closure somewhere. But if I make a code change, everything starts working again just find, so reloading the modules should stop the leak from killing me until I can plug it.</p>
<p>In keeping with the infinite loop idea...I think if you hit the memory cap it resets the global. So maybe if you just wrote 500 MB to memory in one tick it would work.</p>
]]></description><link>http://screeps.com/forum/post/10191</link><guid isPermaLink="true">http://screeps.com/forum/post/10191</guid><dc:creator><![CDATA[black0441]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Force a global reset on Mon, 09 Apr 2018 14:07:34 GMT]]></title><description><![CDATA[<pre><code class="language-js">const heap_bomb = () =&gt; { new Uint32Array(8*1024*1024); heap_bomb(); };
heap_bomb(); 
</code></pre>
<p>I've tried this code -- works fine, but takes 2 ticks to reset global. As I see, for now the only way to force global reset is &quot;heap overflow&quot; or critical error, but one does not simply throw a critical error from sandbox <img
      src="http://screeps.com/forum/plugins/nodebb-plugin-emoji/emoji/android/261d.png?v=a1k070tfs06"
      class="not-responsive emoji emoji-android emoji--point_up"
      title=":point_up:"
      alt="☝"
    /></p>
<p><strong>UPD:</strong> well, nope, it takes ~10 ticks, jeez <img
      src="http://screeps.com/forum/plugins/nodebb-plugin-emoji/emoji/android/1f605.png?v=a1k070tfs06"
      class="not-responsive emoji emoji-android emoji--sweat_smile"
      title=":sweat_smile:"
      alt="😅"
    /> (at least on PTR):</p>
<pre><code class="language-js">[3:38:10 PM][shard0]GAME TIME 24980814
const heap_bomb = () =&gt; { new Uint32Array(8*1024*1024); heap_bomb(); }; heap_bomb();
[3:38:25 PM][shard0]Script execution timed out ungracefully
[3:38:32 PM][shard0]Script execution timed out ungracefully, restarting virtual machine
[3:38:35 PM][shard0]GAME TIME 24980823 
</code></pre>
]]></description><link>http://screeps.com/forum/post/10196</link><guid isPermaLink="true">http://screeps.com/forum/post/10196</guid><dc:creator><![CDATA[Mototroller]]></dc:creator><pubDate>Mon, 09 Apr 2018 14:07:34 GMT</pubDate></item><item><title><![CDATA[Reply to Force a global reset on Invalid Date]]></title><description><![CDATA[<p>A code push also triggers a new reset iirc.</p>
]]></description><link>http://screeps.com/forum/post/10197</link><guid isPermaLink="true">http://screeps.com/forum/post/10197</guid><dc:creator><![CDATA[Joykill]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Force a global reset on Invalid Date]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="http://screeps.com/forum/uid/1622">@joykill</a>, you cannot push code from you code, obviously) See the topic issue:</p>
<blockquote>
<p><em>Is there a way to force a global reset from within the game loop with the iVM architecture?</em></p>
</blockquote>
]]></description><link>http://screeps.com/forum/post/10198</link><guid isPermaLink="true">http://screeps.com/forum/post/10198</guid><dc:creator><![CDATA[Mototroller]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Force a global reset on Invalid Date]]></title><description><![CDATA[<p>So after trying a few ways, I created a module that requires itself. I include that conditionally at the end of the loop, and then I can trigger it by conditionally requiring the module without burning CPU or losing a tick.</p>
<p>Not exactly elegant, but it works.</p>
]]></description><link>http://screeps.com/forum/post/10247</link><guid isPermaLink="true">http://screeps.com/forum/post/10247</guid><dc:creator><![CDATA[black0441]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Force a global reset on Invalid Date]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="http://screeps.com/forum/uid/473">@black0441</a> does <code>Memory</code> get saved for you or are you losing it on the ticks where you trigger this? Are you getting an error when you call this?</p>
]]></description><link>http://screeps.com/forum/post/10311</link><guid isPermaLink="true">http://screeps.com/forum/post/10311</guid><dc:creator><![CDATA[tedivm]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Force a global reset on Invalid Date]]></title><description><![CDATA[<p>Memory is not affected, it's the same thing as a syntax error in a code download.</p>
]]></description><link>http://screeps.com/forum/post/10343</link><guid isPermaLink="true">http://screeps.com/forum/post/10343</guid><dc:creator><![CDATA[black0441]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Force a global reset on Invalid Date]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="http://screeps.com/forum/uid/43">@mototroller</a> said in <a href="/forum/post/10196">Force a global reset</a>:</p>
<blockquote>
<p>const heap_bomb = () =&gt; { new Uint32Array(8<em>1024</em>1024); heap_bomb(); };</p>
</blockquote>
<p>This works in console, but doesn't seem to work in code.</p>
<p>I'm going to test black's solution. Seems like it should work more reliably.</p>
]]></description><link>http://screeps.com/forum/post/11520</link><guid isPermaLink="true">http://screeps.com/forum/post/11520</guid><dc:creator><![CDATA[Tigga]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Force a global reset on Invalid Date]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="http://screeps.com/forum/uid/138">@tigga</a> Are you using TS or some sort of code optimiser? This is not work for me because TS is remove allocation of memory when compiling because this variable is never use.</p>
]]></description><link>http://screeps.com/forum/post/11521</link><guid isPermaLink="true">http://screeps.com/forum/post/11521</guid><dc:creator><![CDATA[Flyasd1]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Force a global reset on Invalid Date]]></title><description><![CDATA[<p>No, the code runs, it just causes my script to timeout rather than blowing out the heap and triggering a reset.</p>
]]></description><link>http://screeps.com/forum/post/11522</link><guid isPermaLink="true">http://screeps.com/forum/post/11522</guid><dc:creator><![CDATA[Tigga]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Force a global reset on Invalid Date]]></title><description><![CDATA[<p>A syntax error doesn't work, nor did the circular require.</p>
<p>Still have no way to do this from code AFAIK.</p>
]]></description><link>http://screeps.com/forum/post/11529</link><guid isPermaLink="true">http://screeps.com/forum/post/11529</guid><dc:creator><![CDATA[Tigga]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Force a global reset on Invalid Date]]></title><description><![CDATA[<p>How about this?</p>
<p>let reset = false</p>
<p>exports.forceReset() = function() {
reset = true
}</p>
<p>module.__initGlobals = function() {
if (!reset ) return
reset = false
throw new Error(&quot;boom&quot;)
}</p>
<p>This will throw an exception outside of the regular evalCode wrapper. I think this will make the vm think it threw the exception and reset the global.</p>
]]></description><link>http://screeps.com/forum/post/11532</link><guid isPermaLink="true">http://screeps.com/forum/post/11532</guid><dc:creator><![CDATA[deft-code]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Force a global reset on Invalid Date]]></title><description><![CDATA[<p>Necromancing this thread because this post was at the top of google search results when I searched for forcing a global reset.</p>
<p>Since the thread was made, the method &quot;Game.cpu.halt()&quot; has been added. It is documented here: <a href="https://docs.screeps.com/api/#Game.cpu.halt" rel="nofollow">https://docs.screeps.com/api/#Game.cpu.halt</a></p>
]]></description><link>http://screeps.com/forum/post/16993</link><guid isPermaLink="true">http://screeps.com/forum/post/16993</guid><dc:creator><![CDATA[wtfrank]]></dc:creator><pubDate>Invalid Date</pubDate></item></channel></rss>