IBM ILOG Solver User's Manual > Extending the Library > Extraction Concepts > Environment and Solver memory allocation

With the distinction between the model and the instance of IloSolver comes two memory pools. The first is linked to the environment. Memory allocated in the environment is reclaimed when the environment is terminated by the member function IloEnv::end. To allocate on this pool, you must pass the env as parameter to the new operator:

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

The second memory pool can be used during search, to store additional information reversibly. To do this, you allocate memory on the Solver heap. The memory allocated with this operator is automatically reclaimed when Solver backtracks to a point before the allocation of the object or if the member function IloSolver::end is called on the instance of IloSolver (this member function is automatically called by IloEnv::end). Therefore, to allocate on the Solver heap, you could write:

MyObject * myobject = new (solver.getHeap()) MyObject();

Note
You must not use the delete operator for objects allocated on the environment memory pool or on the Solver heap. These objects will be deleted when the memory is reclaimed. Note, however, that the destructor of these objects will not be called when the memory is reclaimed.