Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

IloRangeArray::endElements() doesn't release all the memory?

  • 1.  IloRangeArray::endElements() doesn't release all the memory?

    Posted Mon August 30, 2010 05:00 AM

    Originally posted by: zoldfish


    Hi I am using Concert Technology, C++.
    I found it seems that neither IloRangeArray::endElements() nor IloRangeArray::end() can release all the memory it occupied. The code is as follows:
    IloEnv env;
            IloNumVarArray x(env);
            x.add(IloNumVar(env));
            IloRangeArray cons(env);
            IloInt n=0;
            while (1)
            {
                    IloExpr expr=x[0];
                    cons.add(expr<=n);   //add this constraint to cons
                    expr.end();
                    n++;
                    if (env.getMemoryUsage() > 500e6) 
                    {
                            cout<<"Memory usage: "<<env.getMemoryUsage()<<" Bytes"<<endl;
                            cout<<"Number of loops is "<<n<<endl;
                            cons.endElements();        //end all the elements
                            cout<<"After endElements() memory usage: "<<env.getMemoryUsage()<<" Bytes"<<endl;
                            break;
                    }
            }
    


    By calling endElements() method, I hope to release all the memory. However the output of the program turns out to be this :

    Memory usage: 500000088 Bytes
    Number of loops is 3331679
    After endElements() memory usage: 46891776 Bytes
    Press any key to continue . . .

    After the endElements() is called only about 30MB of the memory is released while most of the memory stays. I wonder why it happens like this.

    Thanks a lot!
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: IloRangeArray::endElements() doesn't release all the memory?

    Posted Wed September 08, 2010 12:36 PM

    Originally posted by: SystemAdmin


    As per the numbers given by you, env memory usage decreases to about 47 MB after endElements() whereas, it is 500 MB before ending elements of cons. So, I am not sure why you say: "only 30 MB of the memory is released"...

    If you add the following statements after cons.endElements() then memory usage for env should decrease to about 33 MB.
    x.endElements();
     
                            cons.end();
                            x.end();
    


    It still looks high and I will check with concert developers to see why 33 MB of memory is still in use. My guess is it has something to do with the following statement in document for IloRangeArray:

    "Instances of IloRangeArray are extensible. That is, you can add more elements to such an array. References to an array change whenever an element is added to or removed from the array."

    You might also want to try safe deleter mode because with your sample it slows down the rate of memory increase:
    env.setDeleter(IloSafeDeleterMode);
    

    #CPLEXOptimizers
    #DecisionOptimization