mini-redis icon indicating copy to clipboard operation
mini-redis copied to clipboard

Values inserted into State::pub_sub HashMap are never removed, leaky.

Open cheako opened this issue 4 years ago • 0 comments

https://github.com/tokio-rs/mini-redis/blob/85e19aa21a23914eb317647520e55e34c966dc30/src/db.rs#L225

I'm working on my own project and find it hard to implement a pub_sub system that isn't either manually managing memory(an anti-rust patter IMHO) or forgetting about it altogether as this code does.

Edit/Replace: I wrote what maybe a working solution: https://gitlab.com/cheako/websuite-rs/-/blob/21e9c2e7e2bb31dd0e3f94cc5ae23a17ece8e2c0/naomi/src/lib.rs I didn't use a mpsc for the locking here, because I didn't want to be sending messages in a Drop handler... What do you think?

I'm playing with some ideas, but nothing is working out: https://github.com/tov/weak-table-rs/issues/5 https://gitlab.com/cheako/websuite-rs/-/blob/77258e059853acf9b678049c8016d3545394d2f6/naomi/src/lib.rs#L69 https://gitlab.com/cheako/websuite-rs/-/blob/af387566968a48bb8a8cb574d1baf30eb953d141/naomi/src/lib.rs#L138

Another project struggling with this is feather a minecraft server: https://github.com/feather-rs/feather/blob/e6927044246e258cd0529645429ae83b45a23628/server/chunk/src/chunk_manager.rs#L84

As such, solutions welcome.

cheako avatar Sep 26 '20 17:09 cheako