Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I am using Debian 6 (Squeeze). The server has 4gb of memory in it, and 8gb of swap. I'm starting to get memory alloc errors at high application load times, but from top command:

Mem:   4055944k total,  3915436k used,   140508k free,    10444k buffers
Swap:  7999480k total,        0k used,  7999480k free,  3604496k cached

The system isn't even trying to use the swap?

Why would this be happening? I would like to upgrade the primary memory, but this isn't possible just right now.


As requested, the error/exception is:

terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc ·

which as far as I know, is only ever raised when memory has run out.

Also, here is the output from 'free -m':

             total       used       free     shared    buffers     cached
Mem:          3960       3334        625          0         19       2847
-/+ buffers/cache:        467       3493
Swap:         7811          0       7811

The system is not under heavy load right now though.

share|improve this question
can you show the actual errors you are getting? – stew Jul 8 '12 at 3:05
possible duplicate of How to interpret output from Linux 'top' command? – mgorven Jul 8 '12 at 3:10
Can you provide the output of cat /proc/buddyinfo as close to when the error occurs as is possible? – Patrick Jul 8 '12 at 4:43
What program are you running that throws this error? If we can run apt-get source packagename to look at the source code, that might help solve the problem. How much memory is it trying to allocate and is it forking, using threads, etc? – aculich Jul 8 '12 at 5:18
You have 3.6GB cached, so simply cache is not on the swap. Like this is only with superfetch on Windows 7, that the files are stored on swap – Andrew Smith Jul 8 '12 at 8:05

1 Answer 1

That is the output from top.. Look at the following output

free -m

Then look at the free column for the +/- buffers line. That is your true free memory that apps can use. Linux will use all memory for filesystem caching to take load off the disks and make accessing files very quick. The kernel will release the memory used for caching as needed when applications request it.

I'm sure you have plenty of free memory left.

share|improve this answer
It is my understanding that a program will only crash with the following error: terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc when memory has run out. This is an exception raised by the new operator in c++. – Troy Jul 8 '12 at 3:20
That just means RAM couldn't be allocated. That doesn't mean the system itself has no free RAM. – Joel E Salas Jul 8 '12 at 3:27
What other causes could there be for failure to allocate RAM? – Troy Jul 8 '12 at 4:34
What is free -m supposed to show that the already provided top info doesn't? Its the same data. Used, free, buffers, cache, its all there. – Patrick Jul 8 '12 at 4:46
Biohazard: ulimit -m, for a start. – MadHatter Jul 8 '12 at 5:59

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.