Environment and memory management

The environment handles memory management of the model and algorithm objects.

When your C++ application deletes an instance of IloEnv, Concert Technology will automatically delete all models, algorithms (optimizers) and other objects depending on that environment as well.

To allocate on the environment memory pool in C++, you must pass the environment as an argument to the new operator:


  MyObject*  myobject = new (env) MyObject();

Memory allocated in the environment is reclaimed when the environment is terminated by the member function IloEnv::end. You must not use the delete operator for objects allocated on the environment memory pool. The destructor of these objects will be called when the memory is reclaimed.

To free memory used by a model in the Java™ API, you use the method IloCP.end. To free memory used by a model in the C# API, you use the method CP.End.

Note:

Environment

An instance of the class IloEnv manages the internal modeling issues, which include handling output, memory management for modeling objects and termination of search algorithms.

This instance is typically referred to as the environment. Normally an application needs only one environment, but you can create as many environments as you want.

In the C# and Java APIs, the environment object is not public. To free memory used by a model in the Java API, you use the method IloCP.end. To free memory used by a model in C# API, you use the method CP.End.