[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: browsers have become memory hogs



On Fri, Apr 11, 2008 at 07:10:04AM -0700, Marc Shapiro wrote:
> Is there any way, instead of restricting a resource, to have a command 
> executed when a setpoint for a given resource is reached?  Say, when FF 
> uses 200M of virtual memory, or over 30% of CPU, a job runs which pops 
> up a warning message.  That way you know that a problem exists and can 
> handle it BEFORE it gets to the point where the system is locking up.
> 

Of course there's a way, I just don't know it off the top of my head.

You would write a script that would pole the relavant data.  Probably
the easiest source for data would be to parse the output of vmstat which
gives you cpu and vm data.

Then there's getting the output.  If you want the script to be a
user-focused app, I'd suggest whatever that package is that gives you a
graphical version of dialog with pop-up boxes.  Otherwise, I guess its
using your scripting language of choice (e.g. python) with the
widget-module to match your DTE preference (e.g. wxwindows uses gtk, tk,
qt, etc).

I wouldn't worry so much about %CPU since you can just run FF nice.

Also, remember that the system should not lock up.  The worst case
should be heavy swapping (Thrashing) which means that the system will
eventually respond.  However, if the offending process is running niced,
at least login and bash will have a higher priority.

You may want the script, when it pops up the message, to issue a kill
-STOP and present a button choice (Acknowlege [leave stopped], Continue
[allow FF to continue running with a kill -CONT], or Kill [Kill -KILL]).

I hope this helps get you on the right track.

Doug.


Reply to: