Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  CPLEX does not seem to free the memory

    Posted 03/21/14 02:29 PM

    Originally posted by: Erebos


    Hi all,

    I experience run-time access violations seemingly caused by out-of-memory when I use CPLEX repeatedley to solve MIP problems. I use the CPLEX 12.5 concert API with Visual Studio C++ 2012.

    The following procedure is applied many times. I myself do not construct object in the heap (new). The pseudo code of the function is:

    void testCplex() {
     IloEnv env;
     IloModel model(env);
     IloExpr obj(env);
     IloIntVarArray x(env);
     IloIntVarArray y(env);
     while (condition) {
       ....
       x.add(IloIntVar(env, 0, 1));
     }
     while (condition) {
       ...
       y.add(IloIntVar(env, 0, 1));
       if (q >= x.getSize()) throw string("q >= x-size");
       if (r >= x.getSize()) throw string("r >= x-size");
       if (p >= y.getSize()) throw string("p >= y-size");
       model.add( x[q] + x[r] <= 1 + y[p] );
       obj += y[p] * 1.;
     }
     while (condition) {
       IloExpr flowSum(env);  // Temporary IloExpr ok?
       .......
       model.add (flowSum == 1.);
     }
     ...
     model.add(IloMinimize(env, obj));
     obj.end();
     IloCplex cplex(env); // run-time access violation here!
     ....
    }

    Call stack after crash is: 
    test.exe!IloCplexCache::finitCache(class IloCplexCache * &) C++
    test.exe!IloCplexI::clear(void) C++
    test.exe!IloCplexI::~IloCplexI(void) C++
    test.exe!IloCplexI::`vector deleting destructor'(unsigned int) C++
    test.exe!IloAlgorithm::end(void) Unknown
    test.exe!IloCplex::construct(class IloEnv,bool,struct cpxenv * (*)(char const *,int,char const * const *,int *),char const *,int,char const * const *,void const *) C++

    disassembly:

    00655764  ret 
    00655765  test        ecx,ecx 
    00655767  je          IloCplexCache::finitCache+2Fh (065576Fh) 
    00655769  mov         eax,dword ptr [ecx] 
    0065576B  push        1 
    0065576D  call        dword ptr [eax] 
    0065576F  push        esi 
    00655770  call        dword ptr ds:[0A1A93Ch] 
    00655776  mov         dword ptr [esi],0 
     
    The crash is at 00655767: "Unhandled exception at 0x00655769 in test.exe: 0xC0000005: Access violation reading location 0xFEEEFEEE."

    First question: I generate an all-integer model. However, I always see a single linear variable fixed at zero in the model which I did not add at all. This is an enigma to me. How can this be explained?

    Second question: I figured out that I run out of memory (> 2GB for 32bit processes). Over the time the memory usage increases until it reaches the 2GB limit which then at the 347th model results in the crash.

    It appears to me that the destructors of all the IloXXXobjects won't free all the memory. Is this true? How can I free all the memory used by CPLEX?

    Kind regards


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: CPLEX does not seem to free the memory

    Posted 03/21/14 03:35 PM

    Originally posted by: T_O


    The single continous variable is used by Concert to approximate a possible constant offset to the objective function. You can just ignore it in your case.

    Concering the memory issues, someone who regularly uses Concert shoud answer. I guess, there is something wrong with the .end() statements.

    Best regards,
    Thomas

    P.S.: If you are an academic, you should consider upgrading to CPLEX 12.6.


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: CPLEX does not seem to free the memory

    Posted 03/21/14 03:49 PM

    Do you invoke env.end() before returning from the testCplex() function? If you don't do that you will be leaking memory.


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: CPLEX does not seem to free the memory

    Posted 03/24/14 03:38 AM

    Originally posted by: Erebos


    Both the short answers were also perfect answers! Thx. "env.end()" keeps the allocated RAM below 30 MB.


    #CPLEXOptimizers
    #DecisionOptimization