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

TLS unnecessary allocation and leaks #1838

Closed
rconde01 opened this issue Sep 13, 2019 · 1 comment
Closed

TLS unnecessary allocation and leaks #1838

rconde01 opened this issue Sep 13, 2019 · 1 comment

Comments

@rconde01
Copy link

The OSRPJContextHolder calls init in it's contructor which causes creation/allocation of a proj context for every thread created in a process.

  • This causes allocation on threads that never use proj
  • This is unnecessary because the context is initialized when requested anyhow
  • We have seen that OSRPJContextHolder destructor is not called for all threads using visual studio which causes memory leaks.

The simple solution solution is just to remove this line as it gets initialized when requested anyhow.

@rouault
Copy link
Member

rouault commented Sep 13, 2019

* This causes allocation on threads that never use proj

Interesting... I would have expected the object to be initialized only the first time it is actually used, not when a thread is created (at least, that's how it works on Linux). Anyway someone reported to me about issues with thread_local objects with Visual Studio if GDAL was dynamically loaded in a thread, and I've committed 7014c40 whose side effect should be to avoid OSRPJContextHolder to be constructed unless explicitly called. Nevertheless I've just removed the call to init() in the constructor too

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

No branches or pull requests

2 participants