Re: memory and circle

From: Sammy (samedi@clark.net)
Date: 03/08/96


On Fri, 8 Mar 1996, Romulus.. Imp of Phoenix Mud wrote:

> Is there any way anyone knows to monitor the muds memory
> usage on the machine you are running on while you are in 
> the mud. I know there is no current code for it, but is there
> a system call that anyone knows that would provide such
> information.

Check out getrusage().  It looks like you can get all the info from ps 
with this call.  I've never used it, but I think you would do something 
like this:

#include <sys/time.h>
#include <sys/rusage.h>

void show_usage(struct char_data * ch)
{
  struct rusage *usage;
  int page_size, usage_kbytes;
  char buf[1024];

  if((page_size = getpagesize() < 0) {
    send_to_char("Error attempting to get page size.\r\n", ch);
    return;
  }
  else if((getrusage(RUSAGE_SELF, usage)) < 0) {
    send_to_char("Error attempting to get usage information.\r\n", ch);
    return;
  }

  usage_kbytes = usage->ru_maxrss * page_size / 1024;

  sprintf(buf, "Current memory usage is %ik\r\n", usage_kbytes);
  send_to_char(buf, ch);
  free(usage); /* don't know if this is necessary */
}

This probably won't work as written, but it's a start :)

Sam



This archive was generated by hypermail 2b30 : 12/07/00 PST