<!-- 
RSS generated by JIRA (9.12.2#9120002-sha1:301bf498dd45d800842af0b84230f1bb58606c13) at Sun Jan 12 12:00:36 UTC 2025

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>Mojang Studios Jira</title>
    <link>https://bugs.mojang.com</link>
    <description>This file is an XML representation of an issue</description>
    <language>en</language>    <build-info>
        <version>9.12.2</version>
        <build-number>9120002</build-number>
        <build-date>10-01-2024</build-date>
    </build-info>


<item>
            <title>[MC-3256] Memory leak when starting large TNT chain reactions</title>
                <link>https://bugs.mojang.com/browse/MC-3256</link>
                <project id="10400" key="MC">Minecraft: Java Edition</project>
                    <description>&lt;p&gt;This bug has been in Minecraft for a good while. When starting a chain reaction with several hundreds of TNT blocks involved, the game will start to allocate massive amounts of memory until the virtual machine heap space (-Xmx) is fully exhausted, with the well-known &quot;Out of memory&quot; screen as a result.&lt;/p&gt;

&lt;p&gt;Steps to reproduce: create a superflat world, preset &quot;2;128x46&quot;, ignite any TNT block, wait a few seconds.&lt;/p&gt;

&lt;p&gt;This is caused by the dynamic object pooling for vector and bounding box objects combined with very expensive explosion damage/propulsion calculations.&lt;/p&gt;

&lt;p&gt;Each explosion potentially requires some thousand vectors and a few hundred bounding boxes, whose instances are all stored in a pool for the duration of the current tick.&lt;br/&gt;
&lt;del&gt;Since the pool size isn&apos;t imitated in any way, it stores every single instance in its list.&lt;/del&gt; (&lt;em&gt;Update&lt;/em&gt;: vector lists seem to be controlled in some way since 1.4.x, but it still doesn&apos;t stop them from collecting all objects in one single tick) So if many TNT explosions produce 100 million temporary objects during a tick, everything will be kept in memory and unreachable for the garbage collector until the next tick starts.&lt;/p&gt;

&lt;p&gt;The solution is pretty simple: set a per-tick limit for the object pool list. If a certain limit is passed (I&apos;d recommend 10-20k), return any additional objects always newly constructed so they can be garbage-collected once they&apos;re no longer being used. This also allows the use of fixed-size arrays, which could be a little faster than lists. The attachments below contain some example code that allows me to perform explosions like on a TNT superflat world as above with just 4 GB RAM without any known side effects. (of course, the enormous amount of entities and TNT block meshes will also produce out of memory errors at some point, but much later than in vanilla)&lt;/p&gt;

&lt;p&gt;This obviously won&apos;t fix the FPS performance issues during mass explosions, but at least you&apos;ll be able to see the result after some time without having 32+ GB RAM.&lt;/p&gt;</description>
                <environment>Windows 7 x64, Java 1.7.0_09-b05</environment>
        <key id="15234">MC-3256</key>
            <summary>Memory leak when starting large TNT chain reactions</summary>
                <type id="1" iconUrl="https://bugs.mojang.com/secure/viewavatar?size=xsmall&amp;avatarId=18903&amp;avatarType=issuetype">Bug</type>
                                    <status id="5" iconUrl="https://bugs.mojang.com/images/icons/statuses/resolved.png" description="A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.">Resolved</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="1">Fixed</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="barracuda">Nico Bergemann</reporter>
                        <labels>
                            <label>explosion</label>
                            <label>leak</label>
                            <label>memory</label>
                            <label>tnt</label>
                    </labels>
                <created>Sat, 17 Nov 2012 10:53:34 +0100</created>
                <updated>Wed, 13 Apr 2016 03:40:46 +0200</updated>
                            <resolved>Thu, 24 Jul 2014 23:07:36 +0200</resolved>
                                    <version>Minecraft 1.4.4</version>
                    <version>Minecraft 1.4.7</version>
                    <version>Minecraft 1.5</version>
                    <version>Minecraft 1.6.4</version>
                    <version>Minecraft 1.7.2</version>
                    <version>Minecraft 1.7.5</version>
                                    <fixVersion>Minecraft 1.7.10</fixVersion>
                                                        <votes>2</votes>
                                    <watches>8</watches>
                                                                            <comments>
                            <comment id="299886" author="kyleejane@yahoo.com" created="Wed, 13 Apr 2016 03:40:46 +0200"  >&lt;p&gt;i was using a ipod mod and i used the app explosion and i did explosion power:2000 and my game lagged like freak heck and i tryed loading another world and it crashed with the error: out of ram.&lt;/p&gt;</comment>
                            <comment id="178958" author="barracuda" created="Thu, 24 Jul 2014 14:31:20 +0200"  >&lt;p&gt;I&apos;ve repeated the test with 14w30b and it looks like it won&apos;t run out of memory anymore. I think it has been fixed in 1.7.10 already, since there&apos;s no object pool for vectors anymore, which essentially fixes this issue.&lt;/p&gt;</comment>
                            <comment id="159968" author="jar_" created="Sun, 25 May 2014 09:37:54 +0200"  >&lt;p&gt;Is this still a concern in the &lt;em&gt;current Minecraft version&lt;/em&gt; &lt;b&gt;14w21b&lt;/b&gt; / Launcher version &lt;b&gt;1.4.4&lt;/b&gt; or later? If so, please &lt;em&gt;update the affected versions&lt;/em&gt; in order to best aid Mojang ensuring bugs are still valid in the latest releases/pre-releases.&lt;/p&gt;</comment>
                            <comment id="148042" author="lazypasta" created="Wed, 19 Mar 2014 07:14:21 +0100"  >&lt;p&gt;still happens. i tried it with tnt minecarts (more than about 20) and it lags a bit then crashes&lt;/p&gt;</comment>
                            <comment id="122807" author="barracuda" created="Sun, 1 Dec 2013 09:18:37 +0100"  >&lt;p&gt;Yes, it&apos;s still happening, although the game now shuts down the internal server properly instead of crashing altogether.&lt;/p&gt;</comment>
                            <comment id="106532" author="o_pugs" created="Thu, 26 Sep 2013 18:09:21 +0200"  >&lt;p&gt;Crash report from Launcher 1.2.5, Minecraft version 1.6.4.&lt;/p&gt;

&lt;p&gt;Created superflat world with 64 layers of TNT, ignited with a redstone torch. A few seconds later, &quot;Out of Memory&quot; dialog window, &quot;Minecraft could not continue, as it has run out of memory.&quot;&lt;/p&gt;</comment>
                            <comment id="106468" author="o_pugs" created="Thu, 26 Sep 2013 07:16:12 +0200"  >&lt;p&gt;I saw this problem in 1.6.4, although I haven&apos;t exactly duplicated the&lt;br/&gt;
original poster&apos;s superflat world--I was just trying to make an interesting&lt;br/&gt;
world that I could have a big explosion in. When I searched for the problem&lt;br/&gt;
I had, &lt;a href=&quot;https://bugs.mojang.com/browse/MC-3256&quot; title=&quot;Memory leak when starting large TNT chain reactions&quot; class=&quot;issue-link&quot; data-issue-key=&quot;MC-3256&quot;&gt;&lt;del&gt;MC-3256&lt;/del&gt;&lt;/a&gt; seemed to be the same.&lt;br/&gt;
 I don&apos;t yet feel familiar enough with Atlassian to have posted my report&lt;br/&gt;
file and bug description. I didn&apos;t find the current version lists, for&lt;br/&gt;
example.&lt;/p&gt;

&lt;p&gt;If you haven&apos;t gotten 50 more useful replies by the time you read this, let&lt;br/&gt;
me know, and I&apos;ll be happy to either send my report file as is, or exactly&lt;br/&gt;
duplicate mc-3256 and attach that file, in the morning (I&apos;m in Mountain&lt;br/&gt;
time).&lt;/p&gt;

&lt;p&gt;HTH,&lt;br/&gt;
Carl Feitler&lt;/p&gt;


&lt;p&gt;On Wed, Sep 25, 2013 at 10:42 PM, &lt;span class=&quot;error&quot;&gt;&amp;#91;Mod&amp;#93;&lt;/span&gt; CubeTheThird (JIRA) &amp;lt;&lt;/p&gt;
</comment>
                            <comment id="63200" author="klocko" created="Thu, 25 Apr 2013 05:01:15 +0200"  >&lt;p&gt;There&apos;s a way to remove all of the Primed TNT Entities so you can de-activate the TNT and go back into your world safely, if you have got MCEdit!&lt;/p&gt;

&lt;p&gt;1. Open your world in MCEdit&lt;br/&gt;
2. Find all of the Primed TNT entities&lt;br/&gt;
3. Delete the Primed TNT entities&lt;br/&gt;
4. Also delete whatever triggered the TNT to ensure it doesn&apos;t happen again&lt;br/&gt;
5. Save the world&lt;br/&gt;
6. Open the world in Minecraft&lt;br/&gt;
7. No TNT is activated, so there won&apos;t be any explosions&lt;br/&gt;
8. Enjoy&lt;/p&gt;</comment>
                            <comment id="54121" author="barracuda" created="Sat, 16 Mar 2013 18:00:44 +0100"  >&lt;p&gt;Yes, it is still present in 1.5. I updated the version tags.&lt;/p&gt;</comment>
                            <comment id="22504" author="barracuda" created="Sat, 17 Nov 2012 12:16:26 +0100"  >&lt;p&gt;Added MCP-style code example for fixed object pooling&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10103">
                    <name>Relates</name>
                                            <outwardlinks description="relates to">
                                        <issuelink>
            <issuekey id="27862">MC-12949</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                    </issuelinks>
                <attachments>
                            <attachment id="13437" name="AABBPool.java" size="1742" author="barracuda" created="Sat, 17 Nov 2012 12:16:26 +0100"/>
                            <attachment id="13438" name="Vec3Pool.java" size="1543" author="barracuda" created="Sat, 17 Nov 2012 12:16:26 +0100"/>
                            <attachment id="42510" name="crash-2013-09-26_09.08.58-server.txt" size="4240" author="o_pugs" created="Thu, 26 Sep 2013 18:09:21 +0200"/>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                        <customfield id="customfield_10500" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Confirmation Status</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10300"><![CDATA[Unconfirmed]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                        <customfield id="customfield_11700" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_11100" key="com.atlassian.jira.plugin.system.customfieldtypes:float">
                        <customfieldname>Linked</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                <customfield id="customfield_11600" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>0|i08rlj:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                    </customfields>
    </item>
</channel>
</rss>