placeholder

Fixing Memory Leaks in Rust

Memory leakage in Rust is completely safe...until you run out and it results in your program being killed by the kernel. Learn how we solved this issue to eliminate memory leaks.

Click to view the original at onesignal.com

Hasnain says:

Great read that covers an investigation into a production issue and a fix; while going into some detail about async and observability in Rust

“A few weeks ago, as Journeys adoption started to increase and JourneyX started to process more events, we began to notice a disturbing pattern in its memory usage. The most active processes were consistently utilizing lots of memory, then getting killed by the kernel. The Linux kernel has a piece of functionality called the OOM (out-of-memory) killer, which will automatically kill processes when they consume too much of the system memory. This prevents the system from becoming unstable or locking up due to resource starvation. In our case, the JourneyX processes were constantly being killed, restarted, and killed again by the OOM killer. This showed up on a graph as a sawtooth pattern of rapid allocation and near-instant deallocation when the process was killed. Memory usage would spike up to 17 GiB in the busiest processes, but we expect one of these worker processes to need under 1 GiB.”

Posted on 2022-05-24T04:16:59+0000