randomPoison / cs-bindgen

Experiment in using Rust to build a library that can be loaded by Unity across multiple platforms
4 stars 0 forks source link

Add integration tests for detecting memory leaks #53

Open randomPoison opened 4 years ago

randomPoison commented 4 years ago

Right now it's very easy to accidentally generate code that fails to free Rust-allocated memory, resulting in memory leaks. This is becoming especially prevalent as we flesh out support for marshaling lists of values. As such, it would be very helpful to have integration tests that could automatically detect memory leaks so that we could have more confidence that the generated code is sound.

The big issue here is that I'm not sure how to detect memory leaks coming from unmanaged code on the C# side. For pure-Rust projects we can use tools like valgrind to see the application leaks memory, but in this case we need to specifically verify that the way that the generated C# bindings interact with the Rust code doesn't leak. If we can figure out a way to detect this programmatically, we can setup integrations tests for catching leaks.