saalfeldlab / paintera

GNU General Public License v2.0
99 stars 17 forks source link

Refreshing meshes leaks memory again #393

Closed igorpisarev closed 4 years ago

igorpisarev commented 4 years ago

This is similar to #337 and is occurring again in the most recent release. It wasn't the case in the previous major release 0.22.0 so it must have been introduced somewhere in the process of revamping the mesh managers. I'm currently doing git-bisect to narrow it down.

igorpisarev commented 4 years ago

It seems that the leak was introduced in this commit: https://github.com/saalfeldlab/paintera/pull/383/commits/1be0d52bd55851941b180001bb0367d88042d836 (was a bit tricky to find since some of the commits were squash-merged)

At the first glance, this is the only change in the code that could impact garbage collecting: https://github.com/saalfeldlab/paintera/commit/1be0d52bd55851941b180001bb0367d88042d836#diff-b02ab581d47160bf2251d8ed0ed8a011R271-R274

In general, it could be that the references are held by the listeners and cannot be garbage-collected, but they are already removed explicitly here: https://github.com/saalfeldlab/paintera/commit/1be0d52bd55851941b180001bb0367d88042d836#diff-b02ab581d47160bf2251d8ed0ed8a011R278-R280

I'll look into the changes in the commit more closely to see what else could be causing this.

igorpisarev commented 4 years ago

I think I found the problem: the listener was removed from the object, but it was still kept in the map, therefore all mesh generators (keys) were also kept alive in the map. Removing it from the map fixes it on my machine.