0

I am trying to train a Dlib's train_shape_predictor_ex.cpp with Halen dataset. I compiled the code with Visual Studio in release mode for 64-bit plateform as console application.

When I run the train_shape_predictor_ex.exe in command prompt, the executed process started and I saw in Task Manager that memory consumption by this process was increasing but it was stopped till around 1.9 GB and gave a Run-time Exception: bad allocation. It is unable to take more RAM than around around 1.9 GB RAM even My system is 64 GB RAM

Can anybody help me getting solve this problem? Thanks in advance !

  • 1
    Because this is the maximum allowed for a single application. Your question I think is off topic but did you research it? http://stackoverflow.com/questions/11891593/the-maximum-amount-of-memory-any-single-process-on-windows-can-address – Khalil Khalaf May 24 '16 at 12:45
  • 1
    @FirstStep What do you mean by single application. I have seen in my task Manager that a MySQL application process was using about 16 GB of Physical Memory of total(64 GB) RAM –  May 24 '16 at 12:47
  • 3
    @FirstStep Are you sure? I swear Firefox was sitting at 8.3GB of RAM when I closed it the other day (yes I have a *lot* of tabs) – Borgleader May 24 '16 at 12:47
  • @bor I attached a reference – Khalil Khalaf May 24 '16 at 12:48
  • 7
    You must have built a 32 bit application. – drescherjm May 24 '16 at 12:54
  • 1
    Are you sure you've got more than 2.1 GB free RAM? – ForceBru May 24 '16 at 12:55
  • @drescherjm No ! I have chosen 64 bit option and release mode in Visual Studio to build the application. –  May 24 '16 at 12:55
  • @ForceBru No sorry for mistake.. I didn't get more than **2 GB** or hardly **1.9 GB** –  May 24 '16 at 12:57
  • Please get your values set and stop editing your OP like crazy – Khalil Khalaf May 24 '16 at 13:00
  • 3
    Maybe your allocation is actually bad. I mean if you try to allocate 50TB of memory it will fail. – drescherjm May 24 '16 at 13:00
  • 1
    Perhaps the problem is you are using a 32 bit int to calculate the size of the allocation (and this is wrapping around to negative values because of overflow). Remember that even in 64 bit mode with Visual Studio `int` is 32 bits. – drescherjm May 24 '16 at 13:15
  • 1
    BTW, There is nothing special you need to do on windows to allocate over 2GB of memory on a 64 bit native `c++` application. I have been allocating > 2GB in my 64 bit Visual Studio compiled applications for over a decade. – drescherjm May 24 '16 at 13:22
  • @drescherjm I throught to increase the pagefile size upto 20 GB but it didn't work out. Can you tell me how can I do this. –  May 24 '16 at 13:27
  • 2
    Please use a debugger, and inspect the line of code causing your error. "unable to take more ram" is not how to request help for a c++ coding issue. See [MCVE]. – 2785528 May 24 '16 at 13:30
  • @DOUGLASO.MOEN Thanks for suggestion. I will work on that. –  May 24 '16 at 13:33
  • 5
    Did you accidentally remove the /LARGEADDRESSAWARE flag from your application? Without that flag, you get only 2GB of address space. – Raymond Chen May 24 '16 at 14:32
  • @RaymondChen I am not aware of it. It might happened. I will check it. –  May 24 '16 at 16:13

1 Answers1

2

To build C++ Application which can consume Physical memory than normal 32-Bit application(means 2GB), It is needed to built the application in 64-bit mode.

  • Enable the /LARGEADDRESSAWARE flag to true
  • Build application for 65-bit target CPU.