# The memory remains: Permanent memory with systemd and a Rust allocator

DevFeed: [The memory remains: Permanent memory with systemd and a Rust allocator](<https://devfeed.tech/articles/the-memory-remains-permanent-memory-with-systemd-and-a-rust-allocator-35462.md>)

Original publisher: [Read original article](<https://darkcoding.net/software/rust-systemd-memory-remains/>)

Author: Graham King

Published: 2024-01-10T01:54:00Z

Content type: tutorial

Language: en

Sources: [Graham King](<https://devfeed.tech/sources/graham-king.md>)

Topics: [Rust](<https://devfeed.tech/topics/rust.md>), [systemd](<https://devfeed.tech/topics/systemd.md>), [file](<https://devfeed.tech/topics/file.md>), [Linux](<https://devfeed.tech/topics/linux.md>)

Tags: [assembly](<https://devfeed.tech/tags/assembly.md>), [file](<https://devfeed.tech/tags/file.md>), [function](<https://devfeed.tech/tags/function.md>), [glibc](<https://devfeed.tech/tags/glibc.md>), [layout](<https://devfeed.tech/tags/layout.md>), [memory](<https://devfeed.tech/tags/memory.md>), [mmap](<https://devfeed.tech/tags/mmap.md>), [pointers](<https://devfeed.tech/tags/pointers.md>), [rust](<https://devfeed.tech/tags/rust.md>), [software](<https://devfeed.tech/tags/software.md>), [systemd](<https://devfeed.tech/tags/systemd.md>)

## AI overview

This tutorial explains how to make Rust objects survive program restarts by combining Rust's Allocator trait with systemd's File Descriptor Store and Linux's memfd_create syscall. The approach stores allocator-backed memory in an in-memory file, maps it with mmap, and restores it after restart.

## Source excerpt

A Rust object that survives program restart thanks to Rust allocators, systemd's file descriptor store, and syscall memfd_create.