Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small memory leak #1418

Closed
skinkie opened this issue Jul 18, 2024 · 3 comments · Fixed by #1419
Closed

Small memory leak #1418

skinkie opened this issue Jul 18, 2024 · 3 comments · Fixed by #1419
Labels

Comments

@skinkie
Copy link

skinkie commented Jul 18, 2024

Code Sample, a copy-pastable example if possible

import pyproj # yes this simple

Run this code in heaptrack, and notice that likely osgeo::proj::io::DatabaseContext::create should be freed.

heaptrack python -c "import pyproj"

Problem description

I am currently evaluating performance issues of a python program with respect to memory leaks. I have noticed that, while little, pyproj also has a contribution to it. It is about 2.6MB, small.

Expected Output

No memory allocation expected at the end of the program. But one may also wonder why the DatabaseContext is already created without any calls. I think it may be more elegant to wait for the first call that requires it.

Environment Information

3.6.1 / 9.4.0 / 3.12.4 / Linux-6.9.9-arch1-1-x86_64-with-glibc2.39

Installation method

pacman

@skinkie skinkie added the bug label Jul 18, 2024
@djhoese
Copy link
Contributor

djhoese commented Jul 21, 2024

I'm not sure how I feel about considering this a "leak". If I'm understanding it correctly this is pyproj initializing some state (yes, a database connection, but still). While I'm surprised by the size, who knows what sqlite is doing to pre-load the PROJ database. While it might improve import time to move the database connection/context to be created on first use, this would make execution time inconsistent. This makes performance checks and benchmarking more difficult as you'd have to "warm up" pyproj/PROJ before running anything.

That said, I don't have a good understanding of low-level pyproj, but this is just my initial feeling about this request.

@snowman2
Copy link
Member

#1419 addresses this.

@skinkie
Copy link
Author

skinkie commented Jul 22, 2024

@snowman2 thanks for the effort.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants