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