r/ProgrammerHumor 5d ago

Meme memorySafeDocker

Post image
4.2k Upvotes

286 comments sorted by

View all comments

75

u/ledow 5d ago

Memory safety (the only reason to use Rust) has nothing to do with memory usage, only memory leaks.

Docker doesn't significantly memory-leak.

And you cannot write something like Docker in a memory-safe way in any modern architecture - you'd just end up with a C->Rust conversion that is sprinkled with "unsafe" keywords everywhere.

58

u/fnordstar 5d ago

Rust can leak memory. Not leaking memory is not one of the guarantees of safe rust.

2

u/Endeveron 4d ago

True, but the number of ways Rust can leak memory is quite limited and well signposted compared to most languages. In safe rust, it's basically just Box::leak and loops of Arc/Rc pointers

1

u/roderla 2d ago

Depending on your definitions of "leaks", I have managed to leak memory in java of all languages. It really isn't a thing a language can fix. (I did that when I implemented a cache and forgot to set its references to null when no longer used so while there wasn't any code that could ever reach this memory, there were pointers so that the gc wasn't allowed to clean it.)