Ending objects

Discusses the use of the end method to terminate script objects that are no longer necessary.

The cutstock_main example shows how to end script elements. Although memory leaks are not so much of a concern in this small example, it is good practice to use the end method of the class IloOplModel to systematically terminate objects that are no longer necessary. See IloOplModel. end in the IBM ILOG Script Reference Manual for details.

The end method is set to true by default in the IBM ILOG CPLEX Optimization Studio IDE. This is handled by the script method mainEndEnabled.

thisOplModel.settings.mainEndEnabled = true;

When this setting is enabled (= true), you must ensure that memory is properly managed by your script. Faulty memory management, such as attempting to use an object after it has been deleted, may result in crashes.