5
lorentz
2d

I came up with a really intuitive way to create a coroutine in Rust by passing the sender of an mpsc queue to a callback, then merging the receiver of the same mpsc with the future returned by that callback, but I must've cocked up somewhere because I'm pretty sure it leaks memory.

MPSC ports don't own each other in either direction, that was my first guess too.

Comments
  • 3
    How are you measuring the leak? Mem allocators are generally pretty lazy about giving memory back so a reasonable increase in memory over time might be normal behaviour
  • 5
    @12bitfloat A very very very important Drop callback is not being called
  • 2
    God damn it, I need to write a fucking log aggregator script to figure out where the refcount math is going wrong. I didn't choose Rust for this.
  • 2
    Actually, it'll probably be easier to do it on paper, and this is exactly why I chose Rust. I shudder to think what this would be like if I was also dealing with segfaults emerging from incorrect in-process memory management alongside the panics, errors and leaks emerging from incorrect interprocess resource dependency tracking.
Add Comment