-
Rust]Correct way to call gpu-alloc.rs dealloc() in Drop-Reddit-GameDev코딩Coding/★Rust★Crates.io★ 2022. 2. 7. 16:47728x90
Correct way to call gpu-alloc.rs dealloc() in Drop
I try to allocate memory for Vulkan buffer using gpu-alloc.rs. I store my buffer related variables in MyBuffer struct and initialize them during *MyBuffer::new()*. Also, I want to destruct my buffer using Drop trait.
But if I call *allocator.dealloc()* in *MyStruct::drop()*, I got error:
`'cargo run' terminated by signal SIGSEGV (Address boundary error)`
If I call *dealloc()* at the end line of *MyBuffer::new()*, everything works.
Why is that?
​
`MyBuffer {`
`allocator,`
`...`
`}`
`impl Drop for MyBuffer {`
`fn drop(&mut self) {`
`let block = self.block.take().unwrap();`
`unsafe { &self.allocator.dealloc(EruptMemoryDevice::wrap(&self.device), block); }`
`}`
reference example: [
https://github.com/zakarumych/gpu-alloc/blob/master/examples/src/erupt.rs](
https://github.com/zakarumych/gpu-alloc/blob/master/examples/src/erupt.rs반응형'코딩Coding > ★Rust★Crates.io★' 카테고리의 다른 글
Rust) AaronErhardt/Relm4: An idiomatic GUI library … (0) 2022.02.28 Bevy Jam #1 has started! The theme is Unfair Advantage (0) 2022.02.26 Announcing Actix Web v4.0 (0) 2022.02.26 Rust]build a CRATE , from Scratch to PUBLISHED-Jeremy Chone (0) 2022.02.21 Rust_Watches over your Cargo project’s source(cargo watch) (0) 2022.02.05 Rust]Rocket+Diesel(mysql) (0) 2022.02.04 New library for GPU-less 2D display in winit, looking for..(user.rust.-lang.org (0) 2022.02.03 Rust for Windows윈도우창 나오게 하기 (0) 2022.01.30