Just dont let fanaticism blind you. Had rust dev team refuse for weeks to acknowledge a memory leak in prod no matter how much proof. Basically took the fix PR WITH tests to get them to acknowledge it. especially when using 3rd party libs that use unsafe etc
I hate rust. Unfortunately I'm forced to use it at work.
I found a fun memory leak just this past week in the rust program I'm working on. It's largely not-my-code and I've been slowly fixing and rewriting it.
Rust uses glibc under the hood. When multi-threaded Rust code rapidly creates and deletes vectors, glibc hoards that freed memory in internal pools (like thread caches and arenas) rather than returning it to the Linux kernel, intending to speed up future allocations.
However, if even a single tiny, active piece of memory sits at the top of an arena, it acts as a deadbolt, trapping all the empty deleted space beneath it and causing the application's memory usage to steadily balloon over time. So every vector create and delete was causing new arenas to be allocated, while old ones were never deleted.
Under the hood, rust loves creating and allocating new vectors on the heap instead of reusing anything. C++ will often just pass around the same heap pointer for reuse. This can cause more heap fragmentation in rust vs c++. In testing with identical code blocks that rapidly create and destroy large standard vectors (std::vec and std::vector), the rust code will leak while the c++ code does not. It's frustrating.
We were leaking around 64 MB/s. I had to manually garbage collect and trim this nonsense. I also hoisted and reused the vectors, so they aren't constantly being created and destroyed and fragmenting the heap.
I'm not saying c++ is perfect and memory safe, but I've personally had more weird memory management issues and leaks with rust than I have with c++.
Edit: I also hate how many things that are standard in c++ aren't standard in rust and require using some third-party crate. With all of the supply chain attacks going on (npm, pypi, etc), it's only a matter of time before rust crates get hit. It's just a larger threat surface.
I don't worry about c++'s std:: stealing credentials and git keys, but who knows if joe blow's rust rewrite has been compromised recently.
I mean, not if your program is required to run in constant memory they're not. Or in bounded memory without swap/overcommit, e.g. running on bare metal on a microcontroller.
(Or, just to make up a scenario, if there's a certain system configured such that the OOM killer is free to choose a process to kill at random [i.e. the default OOM-killer policy]; and there's also some process on that system responsible for either your application- or machine-level security; and whatever layer of protection that process adds is simply bypassed if that process dies...)
View all comments
Show parent comment
2
u/Suspicious-Click-300 Oct 22 '26
Just dont let fanaticism blind you. Had rust dev team refuse for weeks to acknowledge a memory leak in prod no matter how much proof. Basically took the fix PR WITH tests to get them to acknowledge it. especially when using 3rd party libs that use unsafe etc