[clug] nice.... but for memory?

Peter Barker pbarker at barker.dropbear.id.au
Wed Jan 21 13:03:04 GMT 2004


On Wed, 21 Jan 2004, Martin Pool wrote:

> > Now. Problem at hand... the only other thing I can think of which /may/
> > help is bsd process accounting, which I've never used. A short google
> > /does/ mention memory as something it will track. I've always thought of
> > that stuff as "run-it-as-a-batch-and-send-someone-a-bill" sort of thing,
> > though.
>
> It can be pretty entertaining (to a certain sort of person) to see all
> the processes float by, and see which ones are using resources.  You
> can't really see short but intense processes in top or ps.

Just struck me that there's another way you could control the process
/reasonably/ easily. There's always time for a good LD_PRELOAD hack,
right?

Andrew - LD_PRELOAD hacks basically allow you to substitute your own code
into place when something makes a library call. If the process is
allocating memory with "malloc", you can substitute your own code to do
pretty much whatever you like (including summing memory allocations from
the process group and making decisions based on that). Kill the process,
cause it to sleep a while, send some mail, reboot the machine, call in
terrorist threats.... Of course, if you /don't/ return some allocated
memory, things are likely to break (as mentioned earlier... not much point
returning "out of memory", since you could get the same effect with a
ulimit).

This approach would be not for the faint of heart or even vaguely sane.
You're going to end up with a steaming pile of trouble. And probably a
much slower system. But hey; PRELOAD hacks are fun.

And /then/ there's ptrace. Or what the hell - go for the intrusive kernel
module. Sigh. Far too late for this sort of thing.

> Martin

Have fun,
-- 
Peter Barker                          |   N    _--_|\ /---- Barham, Vic
Programmer,Sysadmin,Geek              | W + E /     /\
pbarker at barker.dropbear.id.au         |   S   \_,--?_*<-- Canberra
You need a bigger hammer.             |             v    [35S, 149E]
"They'll need a whole new Orwellian pseudo-crime-name for that... I
 suggest "digital molestation of kittens". -  Jeremi (14640) from Slashdot



More information about the linux mailing list