Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8880417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:09:46+00:00 2026-06-14T20:09:46+00:00

I install the latest version of cplex, and use it via its JAVA API.

  • 0

I install the latest version of cplex, and use it via its JAVA API.
To avoid the overhead of constructing cplex instance, I use cplex.clearmodel and then create the new model.

But when I use it to do linear programming thousands of times, the memory leak issue is very serious. It consumed more than 2GB RAM.
Does there exist any solution to alleviate the memory leak issue?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T20:09:46+00:00Added an answer on June 14, 2026 at 8:09 pm

    I’ve encountered this issue before when running my linear programs. You must CREATE exactly one object and continue to use only one reference to that object.

    import ilog.concert.*; 
    import ilog.cplex.*; 
    static public class Application { 
        static public main(String[] args) { 
           try {
             IloCplex cplex = new IloCplex(); 
             // create model and solve it 
           } catch (IloException e) { 
              System.err.println("Concert exception caught: " + e); 
           }
         }
       }
    

    This issue is

    IloCplex cplex = new IloCplex(); 
    

    Only call the above line once in your program. If the clearModel method isn’t working, clear all your constraints, clear your objective function, and clear your cuts individually and then reset your constraints and objective function, but do not create a new object. That is what is causing the memory leak. To solve your new model, use

    cplex.solve()
    

    I imagine your code looks something like this

    import ilog.concert.*; 
    import ilog.cplex.*; 
    public class Example { 
    public static void main(String[] args) { 
        try { 
          for(int i = 1;i <= 5;i++){ // Loop with indices that you may use to create your constraints and objective function.
          IloCplex cplex = new IloCplex(); // Cause of memory leak
          double[]    lb = {0.0, 0.0, 0.0}; 
          double[]    ub = {40.0, Double.MAX_VALUE, Double.MAX_VALUE}; 
          IloNumVar[] x  = cplex.numVarArray(3, lb, ub); 
          double[] objvals = {1.0, 2.0, 3.0}; 
           cplex.addMaximize(cplex.scalProd(x, objvals)); 
          cplex.addLe(cplex.sum(cplex.prod(-1.0, x[0]), 
                                cplex.prod( 1.0, x[1]), 
                                cplex.prod( 1.0, x[2])), 20.0); 
          cplex.addLe(cplex.sum(cplex.prod( 1.0, x[0]), 
                                cplex.prod(-3.0, x[1]), 
                                cplex.prod( 1.0, x[2])), 30.0); 
          if ( cplex.solve() ) { 
            cplex.out().println("Solution status = " + cplex.getStatus()); 
            cplex.out().println("Solution value  = " + cplex.getObjValue());
            double[] val = cplex.getValues(x); 
            int ncols = cplex.getNcols(); 
            for (int j = 0; j < ncols; ++j) 
               cplex.out().println("Column: " + j + " Value = " + val[j]); 
          }
          cplex.end(); 
        }
        }
        catch (IloException e) { 
    System.err.println("Concert exception '" + e + "' caught"); 
        }
      }
    }
    

    Start your for or while loops after you create your instance of the IloCplex object. So, in contrast to the code above, do

    IloCplex cplex = new IloCplex(); // Cause of memory leak
    for(int i = 1;i <= 5;i++){ // Loop with indices that you may use to create your constraints and objective function.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I`m keen to install the latest version of the R XML package on Windows
I'm trying to install the latest version of #Develop but am getting the message
I install ruby via rbenv-installer . When I use irb console, I can use
I'm using Ubuntu 10.04 LTS, and was trying to install the latest version of
How do I install the latest version of fabric on debian? When calling apt-get
Hi I am trying to install the latest version of treectrl ( http://tktreectrl.sourceforge.net/ )
Interested in using Sphinx for my application. Planning to install their latest version which
I want to install latest stable version of Sphinx ( sphinxsearch.com ) on Mac
I'm trying to install the latest pre-release version of HoboFields , which supports Rails
I am trying to install the latest version of Gearman. However, it keeps giving

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.