0

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.

Thanks.

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.

goji
  • 245
  • 1
  • 3
  • 9
  • can you show the actual errors you are getting? – stew Jul 08 '12 at 03:05
  • possible duplicate of [How to interpret output from Linux 'top' command?](http://serverfault.com/questions/377617/how-to-interpret-output-from-linux-top-command) – mgorven Jul 08 '12 at 03:10
  • 1
    Can you provide the output of `cat /proc/buddyinfo` as close to when the error occurs as is possible? – phemmer Jul 08 '12 at 04: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 08 '12 at 05: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 08 '12 at 08:05
  • The application creates a lot of threads. Each thread seems to love to allocate a load of virtual memory. It is hard to say how much it is trying to allocate, as it is a LOT of smaller allocations, no large block allocations. – goji Jul 08 '12 at 08:29

1 Answers1

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.

Mike
  • 21,910
  • 7
  • 55
  • 79
  • 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++. – goji Jul 08 '12 at 03:20
  • 3
    That just means RAM couldn't be allocated. That doesn't mean the system itself has no free RAM. – Joel E Salas Jul 08 '12 at 03:27
  • What other causes could there be for failure to allocate RAM? – goji Jul 08 '12 at 04: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. – phemmer Jul 08 '12 at 04:46
  • 1
    Biohazard: `ulimit -m`, for a start. – MadHatter Jul 08 '12 at 05:59
  • ulimit -m is unlimited – goji Jul 08 '12 at 08:30