diff --git a/tokio/src/runtime/handle.rs b/tokio/src/runtime/handle.rs index 3fa012eb0e8..dbd7f47ebee 100644 --- a/tokio/src/runtime/handle.rs +++ b/tokio/src/runtime/handle.rs @@ -193,7 +193,11 @@ impl Handle { F: FnOnce() -> R + Send + 'static, R: Send + 'static, { - self.spawn_blocking_inner(func, None) + if cfg!(debug_assertions) && std::mem::size_of::() > 2048 { + self.spawn_blocking_inner(Box::new(func), None) + } else { + self.spawn_blocking_inner(func, None) + } } #[cfg_attr(tokio_track_caller, track_caller)]