I am Bored Posted February 23, 2015 Report Posted February 23, 2015 (edited) After digging deeper into the original reason I reported, http://magicduel.invisionzone.com/topic/16288-always-put-semicolons-at-the-end-of-the-line-in-javascript/, I believe I have found the actual cause of the constant 100% CPU usage with massive memory thrashing. In the main page (layout.php), in the <head> tag, there is a reference to: <script type="text/javascript" src="js/popupinfo.js"></script> Normally this wouldn't be an issue, but the problem is, that script writes a <div> tag to the document. Because Firefox uses speculative parsing (https://developer.mozilla.org/en-US/docs/Web/HTML/Optimizing_your_pages_for_speculative_parsing), this causes the entire document to be re-parsed. Note: Everything after this point is informed speculation. Due to the fact it's impossible to disable speculative parsing in Firefox, I cannot be certain that this is in-fact the cause of the issue. Normally this wouldn't be much of an issue, as it's just a single re-parse (admittedly it uses 100mb of RAM to do the re-parse), but the problem comes in when we bring the chat into the picture. The chat refreshes every 5 seconds, and, every time it does so, it modifies the DOM, and, if the document is in the middle of the re-parse from the earlier issue, the entire document will be re-parsed again, from the start. But wait, there's more! It's been another 5 seconds, so we're updating the chat again! This causes the document to once again start re-parsing, and the issue continues. I believe that the solution to this issue is to simply move the <script> tag referenced above out of the <head> tag, and into the <body> tag, as the document.write would be a balanced write, which would no longer cause the initial re-parse, and eliminate the cascading effect that caused the CPU and memory usage issues. Edited February 23, 2015 by I am Bored Burns and Change 2 Quote
Root Admin Chewett Posted February 23, 2015 Root Admin Report Posted February 23, 2015 Thanks for looking into debugging this bored, I think you might be right there :)also: https://www.youtube.com/watch?v=omD3m-xwBWk Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.