zed-industries/zed · error
Arena chunk_size of is too small to allocate bytes
Error message
Arena chunk_size of {} is too small to allocate {} bytes What it means
GPUI's `Arena` is a bump allocator that allocates from fixed-size chunks. When a single allocation does not fit into a freshly created chunk, the arena panics, because it never splits one allocation across chunks — the `chunk_size` is simply too small for the requested layout. This is a configuration bug in the arena's constructor, not a recoverable condition.
Solutions
- Increase the arena's `chunk_size` so it is at least as large as the biggest single allocation you make (ideally several times larger).
- Check the requested `layout.size()` at the failing call site and clamp/split oversized allocations before handing them to the arena.
- Fall back to the heap (e.g. `Box`/`Vec`) for allocations that can exceed the chunk size.
Example fix
// before let arena = Arena::new(1024); let p = arena.alloc(large_buffer); // panics: chunk too small // after let arena = Arena::new(64 * 1024); // chunk_size >= max single allocation let p = arena.alloc(large_buffer);
Defensive patterns
Strategy: validation
Validate before calling
// check before allocating through the arena
if layout.size() > arena_chunk_size {
return Err(anyhow!("allocation of {} bytes exceeds arena chunk_size {}", layout.size(), arena_chunk_size));
}
let ptr = arena.alloc(layout); Prevention
- Size the arena chunk_size several times larger than your largest expected allocation.
- Route oversized or variable-size payloads to the heap instead of the arena.
- Add an assertion at construction time that chunk_size covers known maximum allocation sizes.
When it happens
Trigger: Calling `Arena::alloc` (via `allocate_next_chunk`) with a `Layout` whose size exceeds the arena's configured `chunk_size`, e.g. one very large string/buffer allocated through an arena whose chunk size is smaller.
Common situations: Constructing an arena with a hard-coded small chunk size and later feeding it unusually large payloads (big text buffers, large images); increases in data size after a chunk_size was tuned.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- blocking sender returned without value
- cannot while it is already being updated
- compute_indents_fn is required for UniformListDecoration
- database not initialized
- Expected to render a table row
AI-assisted analysis of zed-industries/zed@916fc2b8cb (2026-09-19).
Data as JSON: /api/errors/81f8b357afbf8523.
Report an issue: GitHub.
Appendix: source
Thrown at crates/gpui/src/arena.rs:209
}
}
#[inline(never)]
fn allocate_next_chunk(&mut self, layout: alloc::Layout) -> *mut u8 {
self.current_chunk_index += 1;
if self.current_chunk_index >= self.chunks.len() {
self.chunks.push(Chunk::new(self.chunk_size));
assert_eq!(self.current_chunk_index, self.chunks.len() - 1);
log::trace!(
"increased element arena capacity to {}kb",
self.capacity() / 1024,
);
}
let current_chunk = &mut self.chunks[self.current_chunk_index];
if let Some(pointer) = current_chunk.allocate(layout) {
pointer.as_ptr()
} else {
panic!(
"Arena chunk_size of {} is too small to allocate {} bytes",
self.chunk_size,
layout.size()
);
}
}
}
pub struct ArenaBox<T: ?Sized> {
ptr: *mut T,
valid: Rc<Cell<bool>>,
}
impl<T: ?Sized> ArenaBox<T> {
#[inline(always)]
pub fn map<U: ?Sized>(mut self, f: impl FnOnce(&mut T) -> &mut U) -> ArenaBox<U> {
ArenaBox {
ptr: f(&mut self),View on GitHub (pinned to 916fc2b8cb)