Skip to content

[Bug] Memory leak during repeated Z-Image-Turbo generations — RAM grows linearly, ends in SIGKILL #10156

Closed

Description

@gavrilich71-bot

Title: [Bug] Memory leak during repeated Z-Image-Turbo generations — RAM grows linearly, ends in SIGKILL

Environment

  • Unsloth Studio: installed 2026-08-31 (native Linux install via install.sh)
  • OS: CachyOS (Arch-based Linux)
  • GPU: NVIDIA RTX 4070 Ti, 12GB VRAM, driver 610.57.04, CUDA UMD 13.3
  • RAM: 31.1 GiB total
  • Model: unsloth/Z-Image-Turbo-unsloth-bnb-4bit (diffusers pipeline)
  • Python 3.12 venv (uv), torch 2.11.0+cu130

Description

When generating multiple images in a row with Z-Image-Turbo-unsloth-bnb-4bit, system RAM usage grows approximately linearly with each generation and is never released back. Eventually RAM + swap are fully exhausted and the OS OOM killer sends SIGKILL to the Unsloth Studio process, crashing the app entirely.

Reproduction

  1. Load unsloth/Z-Image-Turbo-unsloth-bnb-4bit in Unsloth Studio (image generation tab)
  2. Generate an image with any prompt
  3. Generate another image
  4. Repeat 4-5 times
  5. Observe RAM in htop/btop climbing after each generation, never dropping back
  6. After ~5 generations, the main unsloth python process is killed by SIGKILL

Evidence

RES of the main unsloth python process (PID 10716), measured via btop, before/after each generation:

Time unsloth RES System RAM used Swap Available
before any generation 9.0 MB 13.2 GiB (43%) 7% 17.8 GiB
after ~2 generations 16 GB 21.5 GiB (69%) 10% 9.54 GiB
after ~3-4 generations 19 GB 24.7 GiB (80%) 12% 6.34 GiB
after 5 generations 17 GB 30.2 GiB (97%) 38% 895 MiB (3%)

Server log ends with:

fish: Job 1, 'unsloth studio -p 8888' terminated by signal SIGKILL (Forced quit)

Relevant log line at model load:

diffusion.loaded: repo=unsloth/Z-Image-Turbo-unsloth-bnb-4bit base=unsloth/Z-Image-Turbo-unsloth-bnb-4bit device=cuda offload=model tiling=True reasons=companions exceed budget; whole-module offload of every component

This suggests the whole-module CPU offload path (used when VRAM can't hold all pipeline components) may be the source — possibly references to offloaded tensors/latents from prior generations not being released between calls.

Expected behavior

RAM usage should return to baseline (or close to it) after each generation completes, not accumulate indefinitely.

Related issues

This may be related to the broader pattern of Studio not releasing memory described in #6304 (diffusion model memory saturation) and #9033 (system RAM not released after GGUF model load — including on this same Qwen3.8-27B-GGUF model).

Workaround

Restarting unsloth studio every 2-3 generations avoids the crash but is obviously not a long-term fix.

Activity

  1. self-assigned this
    on Sep 2, 2026
  2. added 3 commits that reference this issue on Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions