vpython / vpython-jupyter

3D visualization made easy
MIT License
138 stars 65 forks source link

How to delete a box object that has been added? #203

Open liuxing-GitHub-lx opened 2 years ago

liuxing-GitHub-lx commented 2 years ago

I need to add many box object and sometimes delete them, but using function del does not take effect. setting their attribute visible to invisible , and them still exists in memory. What should I do?

BruceSherwood commented 2 years ago

Take a look at a display of memory and I think you'll find that this just isn't an issue, because a box object uses very little memory. It's my understanding that garbage collection takes place automatically when the list of references to an object goes to zero, but note that in the graphics environment this rule isn't adequate, because an additional reference is the user looking at the 3D object. If you really due have a problem, a suitable approach is make a pool of boxes and reuse ones that been made invisible.