Hi,
According to the
Memory Management section in his reference manual for C++ (
http://www.gurobi.com/documentation/5.6/reference-manual/cpp_reference_manual), we should delete
GRBEnv or
GRBModel objects when they are no longer in used.
However, when I look into the example codes, for instance, mip1_c++.cpp, I don't see any delete calls to free these objects. Is it safe to do so ?
The way the objects are created in the mip1_c++.cpp:
GRBEnv env = GRBEnv();
GRBModel model = GRBModel(env);So creating these objects in this way, is it true that I don't need to delete them later ? I tried to delete them using:
delete env;
delete model;However it prompted errors:
"error: type ‘class GRBModel’ argument given to ‘delete’, expected pointer"I also cannot delete any GRBVar objects although they wrote that "Some Gurobi methods return an array of objects or values.
For
example,
GRBModel::addVars
returns an array of
GRBVar objects. It is the user's
responsibility to free the returned array (using
delete[]).
The reference manual indicates when a method returns a heap-allocated
result."
Please kindly advise. I am just new to C++ programming language.
Loc.