zed-industries/zed · error

failed to allocate

Error message

failed to allocate

What it means

Generic allocation failure raised in `DirectXAtlas::get_or_insert_with` (via insert_tile) when `lock.allocate(...)` returns None: the Direct3D atlas texture has no free tile of the requested size (atlas full, or the requested tile exceeds the atlas dimensions). The message is a sentinel from the allocator, not a Win32 error.

Source

Thrown at crates/gpui_windows/src/directx_atlas.rs:90

impl PlatformAtlas for DirectXAtlas {
    fn get_or_insert_with<'a>(
        &self,
        key: &AtlasKey,
        build: &mut dyn FnMut() -> anyhow::Result<
            Option<(Size<DevicePixels>, std::borrow::Cow<'a, [u8]>)>,
        >,
    ) -> anyhow::Result<Option<AtlasTile>> {
        let mut lock = self.0.lock();
        if let Some(tile) = lock.tiles_by_key.get(key) {
            Ok(Some(*tile))
        } else {
            let Some((size, bytes)) = build()? else {
                return Ok(None);
            };
            let tile = lock
                .allocate(size, key.texture_kind())
                .ok_or_else(|| anyhow::anyhow!("failed to allocate"))?;
            let texture = lock.texture(tile.texture_id);
            texture.upload(&lock.device_context, tile.bounds, &bytes);
            lock.tiles_by_key.insert(key.clone(), tile);
            Ok(Some(tile))
        }
    }

    fn remove(&self, key: &AtlasKey) {
        let mut lock = self.0.lock();

        let Some(tile) = lock.tiles_by_key.remove(key) else {
            return;
        };
        let id = tile.texture_id;

        let textures = match id.kind {
            AtlasTextureKind::Monochrome => &mut lock.monochrome_textures,
            AtlasTextureKind::Polychrome => &mut lock.polychrome_textures,

View on GitHub (pinned to f4178619ac)

Solutions

  1. Grow the atlas texture or add a second atlas page when allocation fails.
  2. Evict unused tiles (LRU) before failing.
  3. Reject oversized tiles early with a clearer 'tile too large for atlas' error.
  4. Log tile size and current atlas occupancy to diagnose fragmentation.
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at crates/gpui_windows/src/directx_atlas.rs:90 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20). Data as JSON: /api/errors/3b199b1c65f588af. Report an issue: GitHub.