Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Cplex memory problem in Java

    Posted 08/29/10 07:16 PM

    Originally posted by: mrr_1010


    Hi,

    I am having trouble when I need to create an instance of cplex many times within Java. Cplex seems not to clear completely at every iteration, and therefore the process takes longer and longer as the loop goes. I have checked the Java jconsole and it does not seem a heap problem related to java. The memory usage within java is small. Yet, as I loop, the computer needs increasing amounts of RAM and time.

    I use the following commands to clear the model (created with IloCplex model = new IloCplex();):
    model.endModel();
    model.end();
    model = null;

    I always put model.end(); and I have tried also adding the other two options to see if this makes it more likely to be cleared. Any combination of the above commands does not solve the issue.

    The bottom question: is there a cplex command to do something analogous to "killall cplex", so that I get a fresh start at every iteration?

    Many thanks,
    Mar

    PS: I use linux 64 bits, and I am aware of the MKL problem. I have tried to set the environment variable MKL_DISABLE_FAST_MM=1, but the issue remains. I have also tried to use different settings of IloCplex.IntParam.NodeFileInd, IloCplex.StringParam.WorkDir, IloCplex.DoubleParam.WorkMem, IloCplex.DoubleParam.TreLim, with not much success. So far the solution has been to add 8 more Gb of memory...
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Cplex memory problem in Java

    Posted 09/09/10 12:08 PM

    Originally posted by: mrr_1010


    Hi,

    I just wanted to follow up on the question. I have been trying several options, and I could fix the leak in two ways.

    It works if I save the files temporarily with these options (which I previously did not use correctly):
    model.setParam(IloCplex.IntParam.NodeFileInd, 2);
    model.setParam(IloCplex.StringParam.WorkDir, "temp/");
    model.setParam(IloCplex.DoubleParam.WorkMem, 1);
    model.setParam(IloCplex.DoubleParam.TreLim, 1);

    As an alternative, I have taken the loop outside from java, looping through java calls with bash. It has the disadvantage of calling java and cplex at every iteration, but as an advantage I can use the memory in the computer directly instead of creating the temp files in the hard drive, as the memory properly clears.

    If any one has better suggestions, I would be glad to hear about them. :)

    Best,
    Mar
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Cplex memory problem in Java

    Posted 09/09/10 01:05 PM

    Originally posted by: SystemAdmin


    No particular reason to think this would work any better, but have you tried model.clearModel()? If the docs are to be trusted, though, model.end() (which you indicated you already tried) should free up the license -- which I would think would cause CPLEX to shrink its memory footprint. From what you posted, it sounds as though the memory leak is a failure by CPLEX to free up its memory space, rather than a failure to free up the Java heap space used by Concert objects.

    Also, if NodeFileInd=2 is clearing a memory leak, does that mean that temporary files are piling up in the temp directory?

    /Paul

    Mathematicians are like Frenchmen: whenever you say something to them, they translate it into their own language, and at once it is something entirely different. (Goethe)
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Cplex memory problem in Java

    Posted 09/21/10 02:43 PM

    Originally posted by: jpolako


    I had the same problem, and I had implement the Singleton Pattern to use only one IloCplex object and the problem was solved...
    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: Cplex memory problem in Java

    Posted 11/08/13 06:42 AM

    Originally posted by: 3V46_Eduardo_Lalla


    Hello,

    I am having the same problem. I use version 12.3 with visual studio C++ (I know the thread was regarding java, however the problem is the same) and I need to execute a MILP in a loop, because the model changes. I use aEnv().end and aMod.end() but the memory is still increasing.  I copied what it is inside the loop. I just want to execute a MILP finishing it, and then restart the process with all the memory of the past iteration already free. However, I monitor with Task Manager and the memory is not released, but it is still increasing to a memory fault.

    While(termination criterion)

    {

    IloEnv aEnv;
            IloModel aMod(aEnv);
            Solver aSolver(aEnv, aMod);
            if (argc == 4) {
                aSolver.ReadModel("subproblem.txt");
                aSolver.Solve(aEnv, aMod);
            }
    aMod.end();
    aEnv.end();

    }

     

    I hope you can help me.

     

    Eduardo


    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: Cplex memory problem in Java

    Posted 11/08/13 06:59 AM

    Calling aEnv.end() at the end of the loop should release all dynamic storage that was allocated on behalf of aEnv. So this part of your code looks fine. Could it be that there is a memory leak in your Solver class?


    #CPLEXOptimizers
    #DecisionOptimization