mitsuba-renderer/nanogui

Example1.cpp appears to leak memory because of `RenderPass`

LincolnSand opened this issue · 1 comments

I decided to stick logging into the ref counting and Object destruction. I also decided to put in a destructor for ExampleApplication. It properly hits a ref count of 0 and calls the destructor if RenderPass and ImageView are not used (ImageView internally uses RenderPass). If they are used, it fails to ever hit a ref count of 0 and "leaks" memory on program exit and never calls the ExampleApplication destructor. I tracked it back to a std::vector in RenderPass called m_targets that appears to be the reason that it holds these owning references on program exit. It appears this std::vector of ref<Object>'s is never cleared (hence destructing the elements) and so these owning references continue to persist.

I have not found a fix to this bug so far.

If this is intentional behavior, then it is unclear from the documentation and confusing from a user pov.

Hopefully this bug report is detailed enough. I can post exact reproducibility code if needed after some time (I'm quite busy).

FYI, this reference cycle issue is now fixed in on master. For details, see 77b8d98 and e3dcfc5.