nmwsharp / polyscope

A C++ & Python viewer for 3D data like meshes and point clouds
https://polyscope.run
MIT License
1.83k stars 203 forks source link

tidy up on shutdown to allow multiple `init`/`shutdown` cycles per process #299

Open gkoulin opened 1 month ago

gkoulin commented 1 month ago
nmwsharp commented 1 month ago

thanks for this, it would be great to cleanly shutdown & reinitialize (some sloppy engineering on my part that I have put off fixing for many years)

I'm afraid of some subtle bugs due to static variables. I have been gradually removing/consolidating static variables wherever possible, but there are still some hanging around. Also, openGL resource management & shutdown.

After enabling tests, it looks like there's a huge amount of memory being leaked. I think maybe the render::engine is not being freed, and is getting recreated each time? It will take some more debugging; I started looking at this but ran out of time for now.

gkoulin commented 1 month ago

Thanks for the feedback. I can't believe ASAN only checks memory leaks on GCC. That's really strange.

Anyway, I've updated ownership of the engine. render::engine is now a std::unique_ptr<Engine>. All other references to the concrete engine, private to the backend, are essentially weak raw pointers.