Похожие чаты

This section The reference count of Rust drops the variable b,

which decreases the reference count of the Rc<List> instance from 2 to 1. The memory that Rc<List> has on the heap won’t be dropped at this point, because its reference count is 1, not 0.

of the rust book
https://doc.rust-lang.org/stable/book/ch15-06-reference-cycles.html

why is the memory saved on Heap it should be on stack right?

9 ответов

21 просмотр

no, the data behind the Rc is on the heap

// AlenPaulVarghese //- Автор вопроса
// AlenPaulVarghese //- Автор вопроса
Pavlo Myroniuk 🦀
yes

so all atomics based types are also stored on heap?

// AlenPaulVarghese //
so all atomics based types are also stored on heap...

what do you mean? there's nothing atomic inside Rc, that's why it's Rc and not Arc

// AlenPaulVarghese //- Автор вопроса
Artem Starikov
what do you mean? there's nothing atomic inside Rc...

no I was asking Arc, RwLock and Mutex are also stored on heap?

// AlenPaulVarghese //
no I was asking Arc, RwLock and Mutex are also sto...

Arc does store its data on the heap, RwLock and Mutex don't

Похожие вопросы

Обсуждают сегодня

Карта сайта