Skip to content
New issue

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

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

Already on GitHub? # to your account

Tracker does not release memory to OS after cleaning up the torrents BTreeMap #65

Closed
mickvandijke opened this issue Aug 11, 2022 · 1 comment
Assignees
Labels
Bug Incorrect Behavior

Comments

@mickvandijke
Copy link
Member

mickvandijke commented Aug 11, 2022

pub async fn cleanup_torrents(&self) {

Should also resize the torrents BTreeMap after torrent cleanup, so that it can release unneeded memory allocation back to the OS.

@mickvandijke mickvandijke added the Bug Incorrect Behavior label Aug 11, 2022
@mickvandijke mickvandijke self-assigned this Aug 11, 2022
@mickvandijke
Copy link
Member Author

mickvandijke commented Aug 12, 2022

Context:

The tracker stores all torrents with peer information in a hashmap. This hashmap grows and shrinks depending on the amount of torrents and peers it holds.

Problem:

After the inactive_peer_cleanup_interval, the tracker deletes all inactive peers and empty torrents from the aforementioned hashmap. This means that theoretically the hashmap can shrink from 10,000,000 torrents to 0. The problem is that the hashmap only allocates more memory as it grows, but doesn't free this memory when it shrinks.

Similar problems:

So apparently it is expected behaviour to keep the allocated memory of the OS even though it is not being used. I could not find a way to free this memory back to the OS.

We also don't want the hashmap to grow beyond the memory available from the OS. So maybe we should give the hashmap a configurable fixed size and replace the most inactive torrent with the newly announced torrent when the hashmap is full during an announce request.

@mickvandijke mickvandijke closed this as not planned Won't fix, can't repro, duplicate, stale Aug 12, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Bug Incorrect Behavior
Projects
Archived in project
Development

No branches or pull requests

1 participant