Bumpalo & Drop , interpretation

I am trying to understand (from bumpalo - Rust )

To deallocate all the objects in the arena at once, we can simply reset the bump pointer back to the start of the arena’s memory chunk. This makes mass deallocation extremely fast, but allocated objects’ Drop implementations are not invoked.

Is the understanding:

(1) by default, bumpalo::Bump DOES call drop handlers -- but we can avoid this by (manually) resetting the start of the arena's memory chunk

(2) by default, bumpalo::Bump frees memory by resetting the start of the arena's memory rhucnk -- thus, by default, Drop handlers are NOT called ?

It's number 2, Drop is not run for anything you allocate into your arena, except when you create the value with bumpalo::boxed::Box. That will run the destructor of T when the Box is dropped.

2 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.