FRAMES NO FRAMES

operator new

public void * operator new(size_t sz, const IloEnv & env)
Definition file: ilconcert/iloenv.h
Overloaded C++ new operator.

IBM® ILOG® Concert Technology offers this overloaded C++ new operator. This operator is overloaded to allocate data on internal data structures associated with an invoking environment (an instance of IloEnv). The memory used by objects allocated with this overloaded operator is automatically reclaimed when you call the member function IloEnv::end. As a developer, you must not delete objects allocated with this operator because of this automatic freeing of memory.

In other words, you must not use the delete operator for objects allocated with this overloaded new operator.

The use of this overloaded new operator is not obligatory in Concert Technology applications. You will see examples of its use in the user's manuals that accompany the IBM® ILOG® optimization products.


operator new

public void * operator new(size_t s, IlcAllocationStack * heap)
Definition file: ilsolver/basic.h
Include file: <ilsolver/ilosolver.h>

Solver provides an overloaded new operator. This operator is overloaded to allocate data on the heap associated with the invoking solver (an instance of IloSolver). The memory used by objects allocated with this operator is automatically reclaimed in these situations:

As a developer, you must not delete objects allocated with this operator because of this automatic freeing of memory.

In other words, the delete operator must not be used for objects allocated on the heap associated with a solver.

The use of this overloaded new operator is not obligatory. In fact, the use of the solver heap is not mandatory. You determine whether Solver uses the overloaded new operator or the conventional C++ new operator when you call the member function useHeap. In particular, you can allocate instances of Solver classes using the standard new operator or even a special purpose allocator. However, some Solver objects contain other objects. For example, Solver variables contain other objects (finite sets) that represent their domains. These subobjects are allocated onto the solver allocation heap. Likewise, constraints are allocated onto the solver allocation heap. Thus, they must not be deleted. Solver manages the corresponding memory transparently.

To allocate an array of size objects of type T on the solver allocation heap, you simply write this:

 T* array = new (s.getHeap()) T [size];

When you do not want to use the solver allocation heap, you write this:

 T* array = new T [size];

When you allocate an array in the way we recommend, it will automatically be de-allocated in either of two situations: if backtracking occurs to a choice point set before this allocation; if the member function end is called for the invoking solver.

See Also: