2

I have a program which does some very intensive graphics work, and requires a lot of memory (> 8GB), however my machine has only 8GB of RAM currently, which means the program throws a bad alloc when it runs out of memory.

Besides this program, I had some other things open that used a bit of my main memory, but mostly it was only the program eating memory.

Now, I wondered why the system throws a bad_alloc when it gets to > 8GB of memory usage, instead of page faulting and swapping out some pages? Isn't that one of the problems that paging and virtual memory is supposed to solve?

I should be able to run my program that requires > 8GB memory, if it were to just page out not recently accessed pages, to be able to create new pages for the required memory.

Can anybody give an explanation?

My machine has a 8GB page file.

Tony The Lion
  • 61,704
  • 67
  • 242
  • 415

2 Answers2

1

There are other issues in memory allocation:

  1. Process Mem allocation: Processes must request a memory frame from the OS. It may be that you have reached the max size the OS can give you
  2. Virtual memory space: Within your process & program, you are working in virtual memory space. Again the process and/or the program that's running may not have the capacity to extend beyond 32 bit

There may be more issues like this that I haven't listed

ControlAltDel
  • 33,923
  • 10
  • 53
  • 80
0

What OS?
How much total ram+swap do you have?

Are you trying to allocate a single contiguous 8Gb region after you have been running for some time? Generaly a bad idea

see How to solve Memory Fragmentation

Community
  • 1
  • 1
Martin Beckett
  • 94,801
  • 28
  • 188
  • 263
  • 1
    I have 8GB of Physical RAM and an 8GB swap file – Tony The Lion Mar 30 '12 at 16:42
  • I'm not so sure what the program is trying to allocate, it's a program doing very high res image editing, so if it loads these in memory, this would be what requires the memory – Tony The Lion Mar 30 '12 at 16:43
  • @TonyTheLion - we were assuming you were writing the software (this is SO) trying to allocate 8Gb in a single block with only 16Gb available isn't goign to work. Try increasing the swap file size - a lot – Martin Beckett Mar 30 '12 at 16:46