MENU

Fun & Interesting

Why does this Rust program leak memory?

fasterthanlime 61,029 2 years ago
Video Not Working? Fix It Now

Follow me on Mastodon: https://hachyderm.io/@fasterthanlime Support my work: https://fasterthanli.me/donate Thanks to Omer from Egypt for submitting this question: https://github.com/mariocynicys/mem-hog Submit your own questions: https://fasterthanli.me/submit Making our own executable packer: https://fasterthanli.me/series/making-our-own-executable-packer Contents 00:00 What does the program do? 04:35 Memory usage, Vec, and jemalloc 06:18 How does malloc even work? 07:22 Visualizing allocations with memusage 11:14 Where is the heap? /proc/PID/maps 14:24 Virtual memory vs RSS 16:00 Tracing syscalls with strace 19:50 Virtual memory vs physical memory 20:50 The madvise syscall 22:31 What's technique 2 doing? 23:37 Iterator size hints 24:56 What's technique 3 doing? 30:31 Mystery solved 34:53 Thanks & outro

Comment