I'm writing a gRPC server in Rust using Tonic, and some of the methods return Stream
s. In order to understand the lifecycle of these requests and whether memory is getting leaked anywhere, I'm using the scopeguard crate to print messages when the Stream
s are getting dropped. I've also tried manually implementing Drop
on some of these Stream
s.
In both cases, I'm seeing results that are difficult to interpret. Some parts of my streaming pipeline are getting Dropped when the client disconnects, and others aren't. These "leaks" aren't necessarily a problem from a performance perspective, it's more that I want to make sure I'm using the libraries correctly, and if memory is getting leaked, I suspect I'm not.
I gather than under normal circumstances (no panics), if drop()
isn't getting called, that means somewhere, someone still owns the value. Is there any way I can see a sort of "ownership stack-trace" to understand why the value hasn't been Dropped?
Ideally I'd understand the ins and outs of the Tonic framework and it'd be clear where to look, but something that can at least point me in the right direction would be a huge help.