0

This line of code produces the following error

rs[se_idx][ev_idx][re_idx].trs = new re_class[report_size];  

std::bad_alloc at memory location 0x0037c29c

I think this is related to 'not enough memory'. When I decrease the amount being allocated, it runs fine.

I have plenty of memory (16 GB) on the machine and a resource monitor shows only a tiny fraction of it is being used by visual studio. I added the compiler options /F 4000000000 and /LARGEADDRESSAWARE, but still getting the error.

How can this be solved?

p.campbell
  • 98,673
  • 67
  • 256
  • 322
user1389840
  • 651
  • 9
  • 24
  • 1
    It just doesn't matter how much RAM is available in your system. See related questions: http://stackoverflow.com/questions/3296840/memory-question http://stackoverflow.com/questions/4385915/realloc-heaprealloc-fails-eventhough-enough-memory-is-available – Naveen May 11 '12 at 16:11
  • 1
    Microsoft's website says: The /LARGEADDRESSAWARE option tells the linker that the application can handle addresses larger than 2 gigabytes. – user1389840 May 11 '12 at 16:30

1 Answers1

1

Are you sure your operating system can take advantage of the entire 16GB and you're using a 64 bit version of VC++

http://msdn.microsoft.com/en-us/library/h2k70f3s%28v=vs.90%29.aspx

http://msdn.microsoft.com/en-us/library/9yb4317s%28v=vs.90%29.aspx

A B
  • 4,068
  • 1
  • 20
  • 23
  • Thanks for the links. Turns out I wasn't using the 64 bit version of VC++. I found good instructions at http://jenshuebel.wordpress.com/2009/02/12/visual-c-2008-express-edition-and-64-bit-targets/ – user1389840 May 11 '12 at 19:35