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

Fixed memory leak in threadpool #1188

Merged
merged 1 commit into from
Feb 24, 2025
Merged

Fixed memory leak in threadpool #1188

merged 1 commit into from
Feb 24, 2025

Conversation

zManu3k
Copy link
Contributor

@zManu3k zManu3k commented Feb 23, 2025

Transitioning from raw pointers (std::thread*) to std::shared_ptr<std::thread> to fix memory leak (there seems to be nothing that delete the raw ptr after the thread is terminated).

  • std::thread objects now are wrapped in std::shared_ptr (so the memory is now automatically managed)
  • CreateThread now creates thread using std::make_shared
  • AddThread has been modified to accept std::shared_ptr<std::thread> instead of raw pointers

@COM8 COM8 added the Bug 🐛 label Feb 24, 2025
@COM8 COM8 added this to the CPR 1.11.x milestone Feb 24, 2025
Copy link
Member

@COM8 COM8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, wow, thanks :D

Nice catch. That's why I started refactoring the thread pool: #1168

I will merge it for the next 1.11.x release. 1.12.0 then will get the fully refactored thread pool once I dealt with the macOS issues in the CI.

@COM8 COM8 merged commit 12ac5f8 into libcpr:master Feb 24, 2025
42 of 44 checks passed
COM8 added a commit that referenced this pull request Feb 24, 2025
Fixed memory leak in threadpool
@COM8
Copy link
Member

COM8 commented Feb 24, 2025

Cherry-picked to the 1.11.x branch and will be part of the 1.11.3 release.

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 this pull request may close these issues.

2 participants