1

When you iteratively call cvxpy.Variables() like

import cvxpy
x = cvxpy.Variable(3)
y = cvxpy.Variable(7)

and then print the internal representation

>>> print x
var3

when repeated several times, the index increases

>>> print x
var121

How to free the memory occupied by the generated variables?

Sergey Dovgal
  • 614
  • 6
  • 21
  • There is no interface for that (as i see it) and i don't see the use-case. Either your variables are used or not. If not, python's garbage-collector should take care. Replacing some x, with some new x should work as expected with only one small unintuitive behaviour: there is a global-counter to generate those id's. But it's just a counter to have some unique-identifier. (Your code looks wrong: the ```s``` in ```cvxpy.Variables``` should not be there) – sascha Jul 21 '17 at 15:50
  • thanks, I fixed the functions. The use case is when I solve a very big optimisation problem, I consume a lot of memory (several gigabytes) and when I want to continue, I need to free it to do something else more efficiently. Perhaps the issue is not with variables, but with some other parts of code, and I can try to manually call the garbage collector, but I just wanted to enquire if there are built-in ways for this. – Sergey Dovgal Jul 21 '17 at 16:47

0 Answers0