Decision Optimization

Decision Optimization

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

 View Only
  • 1.  Why does env.end() not free up memory usage?

    Posted Fri June 28, 2019 12:15 PM

    Originally posted by: lbr33


     

    Hi,

     

    I am using env.end() and variations of that to free up memory after creating and solving a LP model but it does not seem to be working.

    In the mainf function I have a while in which I have someting like that: 

           CPX_flowMAXCUT flowMaxCut;
           IloEnv env = flowMaxCut.env;
           flowMaxCut.mod = IloModel(env);
           flowMaxCut.cplex = IloCplex(flowMaxCut.mod);

           getrusage(RUSAGE_SELF,&r_usage);
           printf("Memory usage before creating and solving the model = %ld\n",r_usage.ru_maxrss);
          

           s = functionThatCreatesAndSOlveTheModel (flowMaxCut);

           getrusage(RUSAGE_SELF,&r_usage);
           printf("Memory usage after creating and solving the model = %ld\n",r_usage.ru_maxrss);
       

           flowMaxCut.cplex.end();
           flowMaxCut.mod.end();
           flowMaxCut.env.end();        

           getrusage(RUSAGE_SELF,&r_usage);
           printf("Memory usage after deleting the structure = %ld\n",r_usage.ru_maxrss);
       
    The value of the memory usage after creating and solving the model is larger than the value of the memory usage before it (as it was expected).

    But, the value of the memory usage after deleting the structure is the same as the value of the memory usage after creating and solving the model.

    Is it normal?

    In the task manager, memory usage keeps increasing.

     

     

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Why does env.end() not free up memory usage?

    Posted Fri June 28, 2019 12:36 PM

    This looks ok, so my guess is that you are leaking something from your functionThatCreatesAndSOlveTheModel(). What happens if you just skip this function in your loop?

    Did you try running your code through valgrind? That is a good tool to find memory leaks.

    Also note that the memory may not immediately be returned to the system, so the different calls to getrusage() may return similar values even though things are released properly. That memory usage builds up over time is a clear indicator for leaks, though :-(


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Why does env.end() not free up memory usage?

    Posted Fri June 28, 2019 01:16 PM

    Originally posted by: lbr33


    If I comment the function ThatCreatesAndSOlveTheModel(), having something like that:

     

           CPX_flowMAXCUT flowMaxCut;
          

          getrusage(RUSAGE_SELF,&r_usage);
          printf("Memory usage before creating and solving the model = %ld\n",r_usage.ru_maxrss);
          

           IloEnv env = flowMaxCut.env;
           flowMaxCut.mod = IloModel(env);
           flowMaxCut.cplex = IloCplex(flowMaxCut.mod);

          

           flowMaxCut.cplex.end();
           flowMaxCut.mod.end();
           flowMaxCut.env.end();        

           getrusage(RUSAGE_SELF,&r_usage);
           printf("Memory usage after deleting the structure = %ld\n",r_usage.ru_maxrss);

     

    I still have the value of memory usage before creating and solving the model smaller than the value of memory usage after deleting the structure.
    So my guess is that the declaration of cplex, model and env increase the memory usage but the .end() is not decreasing it.

     

    I call CPLEX (or declare the model, cplex and env) a LOT of TIMES (around 20000 times).

    Sometimes the memory usage does not change.

    But sometimes it increases and it never decreases.

    I had run valgrind already and I didn't get anything related to that.

    Thank you!!
     


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Why does env.end() not free up memory usage?

    Posted Mon July 01, 2019 02:12 AM

    Like I said, the memory may not be returned to the system immediately. What happens exactly may be a bit random (or at least look random). The question is: does your memory continuously increase? Do you run ouf of memory eventually? If valgrind comes up clean then it would seem a bit odd if you ran out of memory eventually.

    In case you still have trouble with this, can you share your code and data so that we can try to reproduce? If you do not want to share it here, you can share with daniel(dot)junglas(at)de(dot)ibm(dot)com.


    #CPLEXOptimizers
    #DecisionOptimization