[Bug]: WARNING, memory leak with model SDXL (when changing LoRA weights with --pin-shared-memory enabled)
### Checklist
- [ ] The issue exists after disabling all extensions
- [ ] The issue exists on a clean installation of webui
- [ ] The issue is caused by an extension, but I believe it is caused by a bug in the webui
- [ ] The issue exists in the current version of the webui
- [ ] The issue has not been reported before recently
- [ ] The issue has been reported before but has not been fixed yet
### What happened?
I am currently on ec28dcd9b23aac8a4833e13728dab8f6cec2c0c3, I use **--pin-shared-memory**, and sometimes after I change weights of a LoRA (e.g. from <lora:dmd2_sdxl_4step_lora:0.3> to <lora:dmd2_sdxl_4step_lora:0.35> - real example) I get the following warning:
[LORA] Loaded S:\Models\Loras\general\general\dmd2_sdxl_4step_lora.safetensors for SDXL with 788 keys (UNet: 788, CLIP: 0) at weight -0.35
Potential memory leak detected with model SDXL, doing a full garbage collect, for maximum performance avoid circular references in the model code.
WARNING, memory leak with model SDXL. Please make sure it is not being referenced from somewhere.
Potential memory leak detected with model SDXL, doing a full garbage collect, for maximum performance avoid circular references in the model code.
WARNING, memory leak with model SDXL. Please make sure it is not being referenced from somewhere.
Potential memory leak detected with model SDXL, doing a full garbage collect, for maximum performance avoid circular references in the model code.
WARNING, memory leak with model SDXL. Please make sure it is not being referenced from somewhere.
Potential memory leak detected with model SDXL, doing a full garbage collect, for maximum performance avoid circular references in the model code.
WARNING, memory leak with model SDXL. Please make sure it is not being referenced from somewhere.
The generation then starts (the log is spammed with above warnings), but works 2-3 times slower.
Workaround: Settings - Actions - Unload specific model - unload all models (I have 2 allowed in VRAM). Unloading only the current model does not help, all loaded models must be unloaded. After that, the issue goes away.
### Steps to reproduce the problem
1. Generate a few images with <lora:dmd2_sdxl_4step_lora:0.3>
2. Then change weight to to <lora:dmd2_sdxl_4step_lora:0.35> and generate again
3. Warnings appear. If not, repeat generations, changing weights to 0.4, 0.5 and so on; sooner or later, the error will show up.
### What should have happened?
No error should occur
### What browsers do you use to access the UI ?
Google Chrome
### Sysinfo
[sysinfo-2025-12-29-12-24.json](https://github.com/user-attachments/files/24368119/sysinfo-2025-12-29-12-24.json)
### Console logs
```Shell
[LORA] Loaded S:\Models\Loras\general\general\dmd2_sdxl_4step_lora.safetensors for SDXL with 788 keys (UNet: 788, CLIP: 0) at weight -0.35
Potential memory leak detected with model SDXL, doing a full garbage collect, for maximum performance avoid circular references in the model code.
WARNING, memory leak with model SDXL. Please make sure it is not being referenced from somewhere.
Potential memory leak detected with model SDXL, doing a full garbage collect, for maximum performance avoid circular references in the model code.
WARNING, memory leak with model SDXL. Please make sure it is not being referenced from somewhere.
Potential memory leak detected with model SDXL, doing a full garbage collect, for maximum performance avoid circular references in the model code.
WARNING, memory leak with model SDXL. Please make sure it is not being referenced from somewhere.
Potential memory leak detected with model SDXL, doing a full garbage collect, for maximum performance avoid circular references in the model code.
WARNING, memory leak with model SDXL. Please make sure it is not being referenced from somewhere.
```
### Additional information
This behavior started after the latest patches to --pin-shared-memory. If fixing this is too complex, then the suggested dumb workaround would be detecting if LoRA weights changed since last generation and reloading the model.
25 条评论