georust / proj

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

Destroy the threading context object when dropping Proj #15

Closed eminence closed 5 years ago

eminence commented 5 years ago

While I didn't add a test for this issue, here's how you can reproduce the problem:

    #[test]
    fn test_drop() {
        // construct and drop 2000 instances to check for leaks
        for _x in 0..1200 {
            let _proj = Proj::new(
                "+proj=geos +lon_0=0.00 +lat_0=0.00 +a=6378169.00 +b=6356583.80 +h=35785831.0",
            )
            .unwrap();
        }
    }

On my linux machine I have a limit of 1024 open FDs. By constructing 1200 Proj objects, but not property destroying them, I end up with errors opening proj.db ("Too many open files")