# Rust : 메모리 해제를 다른 쓰레드에서 해서 코드를 빠르게 하기

> Clean Markdown view of GeekNews topic #2183. Use the original source for factual precision when an external source URL is present.

## Metadata

- GeekNews HTML: [https://news.hada.io/topic?id=2183](https://news.hada.io/topic?id=2183)
- GeekNews Markdown: [https://news.hada.io/topic/2183.md](https://news.hada.io/topic/2183.md)
- Type: news
- Author: [xguru](https://news.hada.io/@xguru)
- Published: 2020-05-31T10:28:41+09:00
- Updated: 2020-05-31T10:28:41+09:00
- Original source: [abramov.io](https://abramov.io/rust-dropping-things-in-another-thread)
- Points: 12
- Comments: 2

## Topic Body

복잡한 데이터 구조체 같은 것을 Dealloc 할때 시간이 오래 걸리므로,

별도 쓰레드로 구조체를 이관하여 메모리 해제를 처리해서 속도(실제로는 Latency)를 개선하는 팁

→ 1백만개 키를 가진 HashMap의 경우 약 1만배 빠르게 동작하는 효과

## Comments



### Comment 1933

- Author: ryuheechul
- Created: 2020-05-31T19:06:47+09:00
- Points: 1

해당 포스트에서 Rust Playground 가 링크되어 있는 모습을 보고 - https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=e6036d23879b0d0abda5196dfa8a131e

github gist 인가 하고 찾아보니 맞네요 - https://gist.github.com/rust-play/e6036d23879b0d0abda5196dfa8a131e

아마도 플레이그라운드에서 공유버튼을 누르면 깃헙 지스트에 자동으로 저장하는 방식으로 만들어져 있나봅니다.

### Comment 1929

- Author: xguru
- Created: 2020-05-31T10:28:47+09:00
- Points: 1

이런걸 할 때마다 쓰레드를 만드는 코드는 비효율 적일수 있으니, 이 팁을 참고하여 아예 Crate 로 만들어 버린 defer_drop

https://docs.rs/defer-drop/1.0.0/defer_drop/
