public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
From: Jim <Jim@keeliegirl.dyndns.org>
To: gentoo-user@lists.gentoo.org
Subject: Re: [gentoo-user] anyone having apache2 memory issues
Date: Sat, 01 Apr 2006 15:11:49 -0500	[thread overview]
Message-ID: <1143922309.11529.12.camel@keelie.localdomain> (raw)
In-Reply-To: <1143867028.19111.8.camel@phoenix.arcterex.net>

On Fri, 2006-03-31 at 20:50 -0800, Alan Bailward wrote:
> Hey all.  I recently swapped my apache 1.3 site (personal blog, albums,
> etc) over to apache 2 (stable) and all seemed to go well.  However
> lately I've been having a lot of out of memory issues on the server.
> Even when memory is still available 
<snip>

What output do you get from: top -b -n 1

For example, here is my apache output:

jim@keelie$ top -b -n 1
top - 11:48:06 up 2 days, 15:11,  2 users,  load average: 0.00, 0.03,
0.04
Tasks:  88 total,   2 running,  86 sleeping,   0 stopped,   0 zombie
Cpu(s):  7.4% us,  5.0% sy,  0.0% ni, 86.2% id,  0.8% wa,  0.0% hi,
0.5% si
Mem:   2010484k total,  1678576k used,   331908k free,   264884k buffers
Swap:   522104k total,      136k used,   521968k free,   945556k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
15536 root      16   0 56784  10m 4864 S  0.0  0.6   0:00.16 apache2
16374 apache    16   0 57188 9816 3108 S  0.0  0.5   0:00.10 apache2
6481 apache    15   0 57172 9780 3100 S  0.0  0.5   0:00.02 apache2

Go through top and see what is sucking up your memory.  Or you can use
gnome-system-monitor, which I like better.

Here is a little program I tossed together to free that cached memory.
Just run it and specify an amount of memory in MB.  Do not run this as
root, a normal user is fine.


I have 2 GB and after running VMWare I run:

mem 1200

Which frees all that cached memory that VMWare sucked up.  If you have <
1 GB, you should turn swap off before you run this, otherwise you might
just be allocating memory from swap and defeat the purpose.

Before you run the program, look at the output of free to see how much
you should try to free.  For example,

jim@keelie$ free -m
            total  used  free  shared  buffers  cached
Mem:         1963  1643   319        0     258     923
-/+ buffers/cache:  461  1502
Swap:         509     0   509

I have 923 MB sitting in cache.  So if I run:

jim@keelie$ mem 1200
allocating: 1200MB bytes of memory
allocated: 1258291200MB bytes of memory
freed 1258291200MB bytes of memory

I now have 1.2 GB free:

jim@keelie$ free -m
            total  used  free  shared  buffers  cached
Mem:         1963   715  1248       0       45     307
-/+ buffers/cache:  362  1600
Swap:    509          0   509

To compile the program, just do:
You can replace $CFLAGS with whatever you like, for example -O3.

jim@keelie$ gcc $CFLAGS -o mem mem.c
jim@keelie$ sudo cp mem /usr/bin



-------- BEGIN CUT --------
#include <stdlib.h>
#include <stdio.h>

int main(int argc, char* argv[])
{
  char* ptr  = 0;
  int   i    = 0;
  int   size = 0;
  
  if (argc != 2)
  {
    printf("Usage: %s SIZE\nwhere SIZE is the size of "
      "memory to allocate in  MB\n", argv[0]);
    return 1;
  }
  
  /* get the size in MB from the command line */
  size = atoi(argv[1]);
  
  printf("allocating: %iMB bytes of memory\n", size);
  ptr = (char*)malloc(1024 * 1024 * size);
  
  if (ptr)
  {
    printf("allocated: %iMB bytes of memory\n", (1024 * 1024 * size));
    for (i=0; i<(1024 * 1024 * size); i++)
    {
      ptr[i]=1;
    }
    free(ptr);
    printf("freed %iMB bytes of memory\n", (1024 * 1024 * size));
  }
  else
    printf("failed to allocate %iMB bytes of memory\n",
      (1024 * 1024 * size));
  
  return 0;
}
-------- END CUT --------

You might want to try:

# mem 225

Jim
-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
I'm a geek, but I don't get it. 36-24-36 = -24. What's the significance?
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Florida, USA, Earth, Solar System, Milky Way

-- 
gentoo-user@gentoo.org mailing list



  reply	other threads:[~2006-04-01 20:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-01  4:50 [gentoo-user] anyone having apache2 memory issues Alan Bailward
2006-04-01 20:11 ` Jim [this message]
2006-04-01 20:24   ` Alexander Skwar
2006-04-01 21:58     ` Jim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1143922309.11529.12.camel@keelie.localdomain \
    --to=jim@keeliegirl.dyndns.org \
    --cc=gentoo-user@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox