|critical error: cannote allocate memory|
| 5:56 pm on Feb 3, 2008 (gmt 0)|
I am on a dedicated server that hosts 1website.
Sometimes server return me the errror cannote allocate memory, I don't know what should I do...
-Mysql close itself and write into log the too many open file in system
-Apache run normally
-I can't restart mysql because I can't connect to ssh:
Server return me: [SSH] ssh_exchange_identification: Connection closed by remote host
And if I succeed to login to ssh, every command I launch server return me: bash-fork failed:cannote allocate memory
I need help.... I have already write in limits.conf
* soft nofile 4096
but I don't know how to "restart" this file
Very very thanks
| 11:39 pm on Feb 5, 2008 (gmt 0)|
Other errors that I get ( for this problem ) are:
- mail(); Could not execute mail delivery program '/usr/sbin/sendmail -t -i'
- mysql_connect(); Can't create a new thread (errno 12); if you are not out of available memory, you can consult the manual for a possible OS-dependent bug
| 5:04 pm on Feb 6, 2008 (gmt 0)|
|I don't know what should I do... |
- Buy memory
- Limit the amount of httpd processes
- Limit the amount of mysql processes
- Limit the buffersize of mysql
| 10:27 pm on Feb 6, 2008 (gmt 0)|
You're not telling us much.
How much memory do you have?
How big a swap do you have? (Ideally, I like to run without swap ever being touched, but you still need it for exceptional conditions.)
Learn to use "top", learn what the memory statistics mean, and report back what you find.
RAM is cheap. Buy some more. Of course, you will in most cases have to go with a 64-bit OS to go over 4GB.
| 7:56 pm on Feb 8, 2008 (gmt 0)|
I have launch the top command, here the result (after that I reebot the httpd apache):
top - 20:54:44 up 21 days, 8:13, 1 user, load average: 0.38, 0.59, 0.50
Tasks: 43 total, 1 running, 42 sleeping, 0 stopped, 0 zombie
Cpu(s): 4.7% us, 1.2% sy, 0.0% ni, 93.8% id, 0.3% wa, 0.0% hi, 0.0% si
Mem: 6093116k total, 5959908k used, 133208k free, 44948k buffers
Swap: 12586916k total, 4209632k used, 8377284k free, 735896k cached
I don't know what exactly represent this result..
| 11:41 pm on Feb 8, 2008 (gmt 0)|
6 GB RAM should be enough for almost any webserver. So buying more memory is not the easy problem solver here. Only 43 tasks using 6GB RAM plus 4GB swap space is almost unrealistic. You seem to have some elephant of a task somewhere. That could be the mysql database, or some other task has a memory leak and is filling your physical RAM and swap.
If you start top again, it will show you the list of running processes. Which one has the largest value in the VIRT and RES columns? That one is probably the source of your memory problems.
If we know which process is taking your memory, we may be able to give some tuning advice to reduce the memory needs for it.
load average: 0.38, 0.59, 0.50
Cpu(s): 93.8% id
Eventhough your CPU is idle almost 94% if the time, you have an load average of 0.50. This is an indication that tasks are waiting for external events; probably disk I/O caused by swapping in and out large blocks of data.
| 1:02 am on Feb 9, 2008 (gmt 0)|
Actually, the memory report in top is deceptive.
Almost all modern systems will show almost all of memory as "used". You have to subtract-out buffers.
Mem: 2062816k total, 1636544k used, 426272k free, 282656k buffers
This is from my desktop system. I have 2GB installed.
I have 426MB free, but.... 282MB in buffers. The system can "steal" from the buffers (to a point), so I have 426+ (something) free.
But from your listing, yes, it is clear that something is eating up a whole lot of memory, as buffers is a small value. The system has already stolen all it can from buffers.
You've got something eating 10GB of ram. Look at the rest of the output from top (the process list) to see what it is.
Run top again. Hit the "F" (capital F) key while it is running, it will pop-up a list of fields. Hit "N" (capital N) and return. You will now see a list of processes sorted by % memory use.
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
26593 jon 20 0 543m 131m 24m S 0 6.5 0:17.14 eclipse
21470 root 20 0 256m 109m 7568 S 1 5.5 43:40.20 X
21768 jon 20 0 441m 65m 14m S 7 3.3 335:14.40 superkaramba
21817 jon 20 0 418m 36m 16m S 0 1.8 0:06.38 /usr/bin/sealer
21765 jon 20 0 241m 32m 10m S 0 1.6 21:50.00 compiz
2330 mysql 20 0 246m 32m 4288 S 0 1.6 6:08.03 mysqld
Every Linux system has a "man" command. Use it. top is your friend.
| 3:00 am on Feb 9, 2008 (gmt 0)|
very very thanks!
now I have take a screen with the %MEM, VIRT and RES.
Which one has the largest value in the VIRT and RES columns? That one is probably the source of your memory problems.
Hit "N" (capital N) and return. You will now see a list of processes sorted by % memory use.
| 4:56 am on Feb 9, 2008 (gmt 0)|
Sorry, I should have told you to sort by virtual memory. Hit "o" after hitting "F".
I had you sort by resident memory %. Whatever it is that's taking up the memory apparently is mainly swapped-out.
You should wind-up with SOMETHING showing an awfully big VIRT number at the top of the list.
| 12:39 pm on Feb 9, 2008 (gmt 0)|
no problem. Here the result with the sorting of VIRT
there is a mysqld, with 152m ( 152MB? )
| 1:16 pm on Feb 9, 2008 (gmt 0)|
152 megabyte for a mysql process is not exceptional and should not be a problem for this server. Is this a dedicated server where you are the only user, or is it a virtual private server where you share the resources with other users and you are just placed in a virtual box that looks like a full Linux computer, but in effect isn't.
It looks to me that you are not the only one using this machine and that top only shows the processes that belong to you. In that case someone else could be the troublemaker.
| 4:20 pm on Feb 9, 2008 (gmt 0)|
Yes, if this is truly a dedicated machine - or even a true VPS using a hypervisor or paravirtulization, this is not making sense.
The machine appears to be nearly dead-idle, and running with a very nicely slimmed-down set of processes (25 processes?! What Linux machine runs with 25 processes? Mine has 150, but it's a desktop.)
So something "ain't right".
I'm afraid I'm unfamiliar with the details of the virtualization schemes that simply hide other user's resources - maybe somebody else can elucidate more on those. I know these were pretty popular a while back, but I think now are taking a back-seat to true virtualization.
Is this a server you own, or is a monthly lease from a hosting company? How much memory do you get on your plan? The 8GB RAM and 16GB swap does seem awfully high.
If this really is a dedicated server, I don't have any further ideas on what could be wrong, other than to suggest some kind of virus or such (that is eating memory and then hiding itself) or serious mis-configuration of the kernel. If you haven't actually launched your site yet, and/or have good backups and can afford some downtime, I would suggest requesting a full re-load of your system.