-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
What version of OR-Tools and what language are you using?
Version: 9.14.6206
Language: Python
Which solver are you using (e.g. CP-SAT, Routing Solver, GLOP, BOP, Gurobi)
Routing Solver
What operating system (Linux, Windows, ...) and version?
Linux
What did you do?
I use callback for each solution with link on RoutingModel to track the progress of the solution:
callback = SolutionCallback(routing)
routing.AddAtSolutionCallback(callback)
Where callback:
class SolutionCallback:
def __del__(self):
print("DELETE SolutionCallback")
def __init__(self, routing: pywrapcp.RoutingModel):
print("CREATE SolutionCallback")
self.model = routing
def __call__(self):
pass
And in log console I see only "CREATE SolutionCallback".
Memory usage for example from official cite (https://developers.google.com/optimization/routing/vrp) with solution callback (I run it in loop 10_000 times):

I can remove this cyclic reference by:
callback.model = None
After that callback remove.
I didn't find that I need to nullified it in the documentation. I think it is unexpected behavior because by default python can remove cyclic reference.
What did you expect to see
Automatically remove circular references or make a new mention in the documentation that the dependency needs to be nullified