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

vec not free memory. #124249

Closed
zhangxize opened this issue Apr 22, 2024 · 3 comments
Closed

vec not free memory. #124249

zhangxize opened this issue Apr 22, 2024 · 3 comments
Labels
C-discussion Category: Discussion or questions that doesn't represent real issues.

Comments

@zhangxize
Copy link

vec not free momeny.
vectest
main.zip

@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 22, 2024
@zhangxize zhangxize changed the title vec not free momeny. vec not free momery. Apr 22, 2024
@zhangxize zhangxize changed the title vec not free momery. vec not free memory. Apr 22, 2024
@zhangxize
Copy link
Author

Before the 6th attempt, the memory increased slightly and then stopped at 277M

@thynson
Copy link

thynson commented Apr 22, 2024

It is working as intended and depends on the implementation of the memory allocator.

When a Vec is dropped, the corresponding memory is returned to the allocator, while the allocator may keep it for next allocation, instead of returning it to the OS directly.

@saethlin saethlin added C-discussion Category: Discussion or questions that doesn't represent real issues. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Apr 22, 2024
@saethlin
Copy link
Member

saethlin commented Apr 22, 2024

This is a common observation about heap allocators. It's rather vexing, but not releasing memory to the OS is an important optimization.

@saethlin saethlin closed this as not planned Won't fix, can't repro, duplicate, stale Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-discussion Category: Discussion or questions that doesn't represent real issues.
Projects
None yet
Development

No branches or pull requests

4 participants