Stack overflow in Debug even after stack increase, OK in Release

are you calling Box::new() with very large data? if so, this is a known limitation of rust's move semantic. see e.g. #52827.

there exists workaround for some cases, but it depends on what kind of data you are putting into the Box. for instance, if your type can be constructed incrementally in place, you can use Box::new_uninit(). if the data is a large array, try to create a Vec first and then use Vec::into_boxed_slice() to turn it into an Box. if your type can be "zero-initialized", maybe try bytemuck::zeroed_box()

1 Like