first solution for solver: memory leak