x
ChatBox

Please log in with password to access chatbox.
visitor stats
Index | Back | Reply | New Topic

IP Change Automation

Restart Firefox if it takes too much memory
2009-02-24 15:24
utopia.lvI found out that if Firefox takes too much memory, visits are made even 10 times slower than it is with restarted Firefox. So I came up with a script that will restart Firefox process if it takes more than 150Mb of RAM.

Requirements:
* installed Autohotkey program
* Windows XP Pro or higher (or download taskkill.exe from internet and put it into windows/system32 folder).
* browser.sessionstore.resume_from_crash set to FALSE in Firefox about:config

Save the code below in a file, put the file in the same folder where your Supermode automation script is and add to Supermode automation script a new line containing the new script name.

runwait,%comspec% /c taskkill /f /fi "memusage gt 150000" /im firefox.exe >ip_tasks.txt,,hide
sleep 500
FileReadLine,VAR1,ip_tasks.txt,1
stringmid,S1,VAR1,1,200
S1=%S1%
If S1 contains SUCCESS
{
sleep 5000
run,%comspec% /c start firefox.exe -url "http://utopia.lv/exchange/?do=supermode",,hide
}
2009-02-24 18:46
des43tThank you, Uto!

For those of you using batch files, simple insert this at the beginning of your automation file:

taskkill /f /fi "memusage gt 150000" /im firefox.exe

...and this near the end, when you want firefox to open again:

start firefox.exe -url "http://utopia.lv/exchange/?do=supermode"

I have chosen to set the memusage slighly lower, at 100000.

Des
2009-02-25 19:34
hellowienHy Des!

You got a nice batch-solution here, I am impressed how you make progess ... A small failure is in your suggested way to restart firefox as your commandline woud be executed every round, regardless if FF is still running or not what will cause the error-message that another instance of FF is already running. A way to avoid this is, to assign the batch to look for FF running or not before starting. The cmd-command 'tasklist' gives us the option to do this, if FF is running nothing happens, if FF is shutdown via taskkill at memory usage at e.g. 100.000 K FF will be restarted. Here the complete guide:

taskkill /f /fi "memusage gt 100000" /im firefox.exe

*** here your way to refresh IP ***

tasklist |find /i "firefox.exe" >nul
if %errorlevel%==1 start firefox.exe -p Supermode -no-remote -url "http://utopia.lv/exchange/profile.php?w=special&name=yourname&pass=yourpassword&profile=load&loc=supermode"


See forum post http://utopia.lv/exchange/?do=forum&w=view&pid=104 (Link that will automatically log you in) and http://utopia.lv/exchange/?do=forum&w=view&pid=144 (utopias post about creating a new Firefox profile for running Supermode). In case of using an extra profile for Supermode I would suggest following standard-tweaks in about:config

user_pref("network.http.pipelining", true);
user_pref("network.http.proxy.pipelining", true);
user_pref("network.http.pipelining.maxrequests", 8);
user_pref("content.notify.backoffcount", 5);


If you want to get deeper into it, maybe you will try the following ones (only suggested for CPU > 1,5 Ghz, RAM ? 512 MB / fast connection (DSL, cable or faster). They work excellent for me:

user_pref("content.interrupt.parsing", true);
user_pref("content.max.tokenizing.time", 2250000);
user_pref("content.notify.interval", 750000);
user_pref("content.notify.ontimer", true);
user_pref("content.switch.threshold", 750000);
user_pref("nglayout.initialpaint.delay", 0);
user_pref("network.http.max-connections", 48);
user_pref("network.http.max-connections-per-server", 16);
user_pref("network.http.max-persistent-connections-per-proxy", 16);
user_pref("network.http.max-persistent-connections-per-server", 8);
user_pref("browser.cache.memory.capacity", 65536);
2009-03-07 11:56
hellowienUsing 'errorlevel' offers a lot of controlls. As I got stucked with connection problems a lot more times than with site problems I searched for a way to controll if connection is established before starting the exchange. I found the solution in sending a ping to google.com after reconnect. In case the ping was o.k. (errorlevel 0) the batch continous with the exchange, in case of unseccesfull ping (errorlevel 1) - what means no connection - the reconnect procedure starts again. You can add this small codesnippet if you want as addition to your reconnect.bat:

:again
*** here your way to refresh IP ***
ping -n 1 google.com
IF %errorlevel%==1 GOTO again
2009-03-07 12:53
utopia.lvI am using the same solution to verify if IP address is not taken on my LAN (altogather with following ARP check).