Massive memory leak
|
|
ms99, you need to do some serious profiling work on your script, as it has an incredibly huge memory leak that, over time, causes Firefox to absolutely grind to a halt as it uses up all of the system memory. Just a quick observational report-- reloading dorf1.php ten times without Greasemonkey running (or even with GM and having this script disabled) has the memory usage of Firefox to remain at about 74M. Then-- enabling the script. 1 reload: 93M
After an hour or so of actually playing the game with this script on, Firefox can and will use more than 1G of memory, most of which has been leaked. It looks like you're leaking more than 6 megs of memory on each page view?!? |
|
|
@Mark23,
Very appreciated your report. You may have posted it into the "Issue/Bug Reports" thread, but anyway... If you have suggestions I am here for listening. If you have tips, please share them. I would be glad to fix the issues you report but do not really know how. Thank you. |
|
|
Well, I would start by trapping the onbeforeunload event, and routing that to a custom function that returns true after it has done its work. Within that function, I would look at all of the objects you've created on the page, and set them to null. For example, clear out all of your arrays, gidToName, xLang, all the cost arrays, bCost, uc, image, basically anything that uses strings or objects to represent values, set those all to null. Within all of your functions, any complex object that you create should be set to null at the end of the function, just before you return (unless of course you're returning that object). Those two changes alone should do wonders for memory consumption. They won't fix all the leaks, but they'll go a long way. |
|
|
You should try to find an older version of your script that does not have the memory leak and find out what change caused the leak to appear. Meld (linux) and winmerge (windows) are real nice tools for viewing the differences between 2 files. The leak is quite a problem for me. |
![]() ![]() |
More anecdotal evidence, it looks like the bookmarks are a particular abuser. |
![]() ![]() |
@Mark23,
I've followed some of your recommendations. You will see them in the next version of the script. I would like to kindly ask you to share your knowledge with us, the users of this script, if you have some time. Please analyse the code and post your observations/fixes here or send them via mail to the mail address specified in the "Contact" section of the "About" tab of this page. As stated before, I do not play the game anymore and have only test accounts. It is quite difficult to spot out the issues the users report with only test accounts. And spotting out issues regarding memory leaks or garbage collection is even more difficult. Any contribution is welcomed ! And credits go to the contributor. Thank you. |
![]() ![]() |
Well, I've started to look around that memory leak, but I've found nothing. :S
I use this script, my own map analyser script, the building mover script, and a few of my test scripts.
It is true when I reload the pages Firefox uses more memory but automatically sets it free in a minute later. The maximum taken memory was 290MB, but it always keeps around 230MB. And the script version is 3.8.7.3. Booboo |


