Will Box::leak 'static run Drop on Exit?

⚓ Rust    📅 2026-06-24    👤 surdeus    👁️ 1      

surdeus

In the doc examples for LazyLock, I found:

// Note: static items do not call [`Drop`] on program termination, so this won't be deallocated.

This is in reference to having a static X: LazyLock<_> defined.

Does the same logic apply to Box::leak where I'm creating a static reference? Will Drop be called at system exit or will it never be called?

4 posts - 4 participants

Read full topic

🏷️ Rust_feed