georust / proj

Rust bindings for the latest stable release of PROJ
https://docs.rs/proj
Apache License 2.0
137 stars 45 forks source link

Should proj_cleanup be run if there are active contexts? #75

Open frewsxcv opened 3 years ago

frewsxcv commented 3 years ago

This function frees global resources (grids, cache of +init files). It should be called typically before process termination, and after having freed PJ and PJ_CONTEXT objects.

This crate runs proj_cleanup on every Drop for Proj and ProjBuilder. So if you have two Proj instances in your application and one gets dropped, we'll run proj_cleanup even though the other Proj is still alive. My interpretation of the documentation for proj_cleanup (above) is that we should only run proj_cleanup after all other PROJ objects and contexts have been freed.

If this is the case, we'd need to think through how to accomplish this, as Rust has no way to automatically run code when a process ends. We'd have to do some sort of reference counting and only run proj_cleanup if we know there are now Proj instances alive