Repository: stable-diffusion-webui
Issue: [Bug]: Always end up eating all the RAM, even if generation stopped and crashing the PC.😤
Labels: bug-report

### Checklist

- [X] 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?

Generating images with SDXL model and using reactor + IPADAPTER for face replace.

### Steps to reproduce the problem

Generate image, bla, ba...

### What should have happened?

Why it can't **clean/Free up the memory after end generating images**?

Even after the generation stop, the memory keeps at full usage!
And then, ofc. the next generation will end up with a crash!

In ReForge this not happen....

### What browsers do you use to access the UI ?

Mozilla Firefox

### Sysinfo

[sysinfo-2024-08-01-03-40.json](https://github.com/user-attachments/files/16449885/sysinfo-2024-08-01-03-40.json)


### Console logs

```Shell
venv "C:\Users\ZeroCool22\Desktop\AutoSDXL\stable-diffusion-webui\venv\Scripts\Python.exe"
Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug  1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)]
Version: v1.10.1
Commit hash: 82a973c04367123ae98bd9abdf80d9eda9b910e2
CUDA 12.1
Launching Web UI with arguments: --xformers --api --disable-nan-check --medvram-sdxl
CHv1.8.10: Get Custom Model Folder
[-] ADetailer initialized. version: 24.6.0, num models: 10
ControlNet preprocessor location: C:\Users\ZeroCool22\Desktop\AutoSDXL\stable-diffusion-webui\extensions\sd-webui-controlnet\annotator\downloads
2024-08-01 00:40:02,417 - ControlNet - INFO - ControlNet v1.1.455
00:40:03 - ReActor - STATUS - Running v0.7.1-a1 on Device: CPU
Loading weights [3ee9534568] from C:\Users\ZeroCool22\Desktop\AutoSDXL\stable-diffusion-webui\models\Stable-diffusion\1.5\Hyper\creapromptLightning_creapromptHyperCFGV2.safetensors
CHv1.8.10: Set Proxy:
2024-08-01 00:40:03,953 - ControlNet - INFO - ControlNet UI callback registered.
Running on local URL:  http://127.0.0.1:7860

To create a public link, set `share=True` in `launch()`.
Creating model from config: C:\Users\ZeroCool22\Desktop\AutoSDXL\stable-diffusion-webui\repositories\generative-models\configs\inference\sd_xl_base.yaml
Startup time: 32.3s (prepare environment: 12.6s, import torch: 4.5s, import gradio: 0.8s, setup paths: 2.7s, initialize shared: 3.0s, other imports: 1.9s, load scripts: 4.5s, create ui: 0.9s, gradio launch: 0.8s, add APIs: 0.4s).
Loading VAE weights specified in settings: C:\Users\ZeroCool22\Desktop\AutoSDXL\stable-diffusion-webui\models\VAE\sdxl_vae.safetensors
Applying attention optimization: xformers... done.
Model loaded in 36.8s (load weights from disk: 1.2s, create model: 0.9s, apply weights to model: 32.3s, load VAE: 0.7s, calculate empty prompt: 1.5s).
2024-08-01 00:41:45,604 - ControlNet - INFO - unit_separate = False, style_align = False
2024-08-01 00:41:45,806 - ControlNet - INFO - Loading model: ip-adapter-faceid-plusv2_sdxl [187cb962]
2024-08-01 00:41:49,250 - ControlNet - INFO - Loaded state_dict from [C:\Users\ZeroCool22\Desktop\AutoSDXL\stable-diffusion-webui\models\ControlNet\SDXL\ip-adapter-faceid-plusv2_sdxl.bin]
2024-08-01 00:41:51,702 - ControlNet - INFO - ControlNet model ip-adapter-faceid-plusv2_sdxl [187cb962](ControlModelType.IPAdapter) loaded.
2024-08-01 00:41:51,706 - ControlNet - INFO - Using preprocessor: ip-adapter_face_id_plus
2024-08-01 00:41:51,706 - ControlNet - INFO - preprocessor resolution = 972
Applied providers: ['CUDAExecutionProvider', 'CPUExecutionProvider'], with options: {'CUDAExecutionProvider': {'cudnn_conv_algo_search': 'EXHAUSTIVE', 'device_id': '0', 'has_user_compute_stream': '0', 'cudnn_conv1d_pad_to_nc1d': '0', 'gpu_external_alloc': '0', 'gpu_mem_limit': '18446744073709551615', 'enable_cuda_graph': '0', 'gpu_external_free': '0', 'gpu_external_empty_cache': '0', 'arena_extend_strategy': 'kNextPowerOfTwo', 'do_copy_in_default_stream': '1', 'cudnn_conv_use_max_workspace': '1', 'tunable_op_enable': '0', 'tunable_op_tuning_enable': '0', 'tunable_op_max_tuning_duration_ms': '0', 'enable_skip_layer_norm_strict_mode': '0', 'prefer_nhwc': '0', 'use_ep_level_unified_stream': '0'}, 'CPUExecutionProvider': {}}
find model: C:\Users\ZeroCool22\Desktop\AutoSDXL\stable-diffusion-webui\extensions\sd-webui-controlnet\annotator\downloads\insightface\models\buffalo_l\1k3d68.onnx landmark_3d_68 ['None', 3, 192, 192] 0.0 1.0
Applied providers: ['CUDAExecutionProvider', 'CPUExecutionProvider'], with options: {'CUDAExecutionProvider': {'cudnn_conv_algo_search': 'EXHAUSTIVE', 'device_id': '0', 'has_user_compute_stream': '0', 'cudnn_conv1d_pad_to_nc1d': '0', 'gpu_external_alloc': '0', 'gpu_mem_limit': '18446744073709551615', 'enable_cuda_graph': '0', 'gpu_external_free': '0', 'gpu_external_empty_cache': '0', 'arena_extend_strategy': 'kNextPowerOfTwo', 'do_copy_in_default_stream': '1', 'cudnn_conv_use_max_workspace': '1', 'tunable_op_enable': '0', 'tunable_op_tuning_enable': '0', 'tunable_op_max_tuning_duration_ms': '0', 'enable_skip_layer_norm_strict_mode': '0', 'prefer_nhwc': '0', 'use_ep_level_unified_stream': '0'}, 'CPUExecutionProvider': {}}
find model: C:\Users\ZeroCool22\Desktop\AutoSDXL\stable-diffusion-webui\extensions\sd-webui-controlnet\annotator\downloads\insightface\models\buffalo_l\2d106det.onnx landmark_2d_106 ['None', 3, 192, 192] 0.0 1.0
Applied providers: ['CUDAExecutionProvider', 'CPUExecutionProvider'], with options: {'CUDAExecutionProvider': {'cudnn_conv_algo_search': 'EXHAUSTIVE', 'device_id': '0', 'has_user_compute_stream': '0', 'cudnn_conv1d_pad_to_nc1d': '0', 'gpu_external_alloc': '0', 'gpu_mem_limit': '18446744073709551615', 'enable_cuda_graph': '0', 'gpu_external_free': '0', 'gpu_external_empty_cache': '0', 'arena_extend_strategy': 'kNextPowerOfTwo', 'do_copy_in_default_stream': '1', 'cudnn_conv_use_max_workspace': '1', 'tunable_op_enable': '0', 'tunable_op_tuning_enable': '0', 'tunable_op_max_tuning_duration_ms': '0', 'enable_skip_layer_norm_strict_mode': '0', 'prefer_nhwc': '0', 'use_ep_level_unified_stream': '0'}, 'CPUExecutionProvider': {}}
find model: C:\Users\ZeroCool22\Desktop\AutoSDXL\stable-diffusion-webui\extensions\sd-webui-controlnet\annotator\downloads\insightface\models\buffalo_l\det_10g.onnx detection [1, 3, '?', '?'] 127.5 128.0
Applied providers: ['CUDAExecutionProvider', 'CPUExecutionProvider'], with options: {'CUDAExecutionProvider': {'cudnn_conv_algo_search': 'EXHAUSTIVE', 'device_id': '0', 'has_user_compute_stream': '0', 'cudnn_conv1d_pad_to_nc1d': '0', 'gpu_external_alloc': '0', 'gpu_mem_limit': '18446744073709551615', 'enable_cuda_graph': '0', 'gpu_external_free': '0', 'gpu_external_empty_cache': '0', 'arena_extend_strategy': 'kNextPowerOfTwo', 'do_copy_in_default_stream': '1', 'cudnn_conv_use_max_workspace': '1', 'tunable_op_enable': '0', 'tunable_op_tuning_enable': '0', 'tunable_op_max_tuning_duration_ms': '0', 'enable_skip_layer_norm_strict_mode': '0', 'prefer_nhwc': '0', 'use_ep_level_unified_stream': '0'}, 'CPUExecutionProvider': {}}
find model: C:\Users\ZeroCool22\Desktop\AutoSDXL\stable-diffusion-webui\extensions\sd-webui-controlnet\annotator\downloads\insightface\models\buffalo_l\genderage.onnx genderage ['None', 3, 96, 96] 0.0 1.0
Applied providers: ['CUDAExecutionProvider', 'CPUExecutionProvider'], with options: {'CUDAExecutionProvider': {'cudnn_conv_algo_search': 'EXHAUSTIVE', 'device_id': '0', 'has_user_compute_stream': '0', 'cudnn_conv1d_pad_to_nc1d': '0', 'gpu_external_alloc': '0', 'gpu_mem_limit': '18446744073709551615', 'enable_cuda_graph': '0', 'gpu_external_free': '0', 'gpu_external_empty_cache': '0', 'arena_extend_strategy': 'kNextPowerOfTwo', 'do_copy_in_default_stream': '1', 'cudnn_conv_use_max_workspace': '1', 'tunable_op_enable': '0', 'tunable_op_tuning_enable': '0', 'tunable_op_max_tuning_duration_ms': '0', 'enable_skip_layer_norm_strict_mode': '0', 'prefer_nhwc': '0', 'use_ep_level_unified_stream': '0'}, 'CPUExecutionProvider': {}}
find model: C:\Users\ZeroCool22\Desktop\AutoSDXL\stable-diffusion-webui\extensions\sd-webui-controlnet\annotator\downloads\insightface\models\buffalo_l\w600k_r50.onnx recognition ['None', 3, 112, 112] 127.5 127.5
set det-size: (640, 640)
2024-08-01 00:42:13,140 - ControlNet - INFO - ControlNet Hooked - Time = 27.537073850631714
100%|██████████████████████████████████████████████████████████████████████████████████| 15/15 [00:24<00:00,  1.65s/it]
00:43:11 - ReActor - STATUS - Working: source face index [0], target face index [0]
00:43:11 - ReActor - STATUS - Analyzing Source Image...
00:43:14 - ReActor - STATUS - Analyzing Target Image...
00:43:15 - ReActor - STATUS - Detecting Source Face, Index = 0
00:43:15 - ReActor - STATUS - Detected: -58- y.o. Male
00:43:17 - ReActor - STATUS - Detecting Target Face, Index = 0
00:43:17 - ReActor - STATUS - Detected: -51- y.o. Male
00:43:17 - ReActor - STATUS - Swapping Source into Target
00:43:17 - ReActor - STATUS - Restoring the face with CodeFormer (weight: 0.5)
100%|██████████████████████████████████████████████████████████████████████████████████| 15/15 [00:27<00:00,  1.86s/it]
00:44:14 - ReActor - STATUS - Working: source face index [0], target face index [0]
00:44:14 - ReActor - STATUS - Using Hashed Source Face(s) Model...
00:44:14 - ReActor - STATUS - Analyzing Target Image...
00:44:16 - ReActor - STATUS - Detecting Source Face, Index = 0
00:44:16 - ReActor - STATUS - Detected: -58- y.o. Male
00:44:16 - ReActor - STATUS - Detecting Target Face, Index = 0
00:44:16 - ReActor - STATUS - Detected: -48- y.o. Male
00:44:16 - ReActor - STATUS - Swapping Source into Target
00:44:16 - ReActor - STATUS - Restoring the face with CodeFormer (weight: 0.5)
100%|██████████████████████████████████████████████████████████████████████████████████| 15/15 [00:27<00:00,  1.84s/it]
00:45:06 - ReActor - STATUS - Working: source face index [0], target face index [0]
00:45:06 - ReActor - STATUS - Using Hashed Source Face(s) Model...
00:45:06 - ReActor - STATUS - Analyzing Target Image...
00:45:07 - ReActor - STATUS - Detecting Source Face, Index = 0
00:45:07 - ReActor - STATUS - Detected: -58- y.o. Male
00:45:07 - ReActor - STATUS - Detecting Target Face, Index = 0
00:45:07 - ReActor - STATUS - Detected: -52- y.o. Male
00:45:07 - ReActor - STATUS - Swapping Source into Target
00:45:08 - ReActor - STATUS - Restoring the face with CodeFormer (weight: 0.5)
100%|██████████████████████████████████████████████████████████████████████████████████| 15/15 [00:27<00:00,  1.84s/it]
00:45:59 - ReActor - STATUS - Working: source face index [0], target face index [0]
00:45:59 - ReActor - STATUS - Using Hashed Source Face(s) Model...
00:45:59 - ReActor - STATUS - Analyzing Target Image...
00:46:01 - ReActor - STATUS - Detecting Source Face, Index = 0
00:46:01 - ReActor - STATUS - Detected: -58- y.o. Male
00:46:01 - ReActor - STATUS - Detecting Target Face, Index = 0
00:46:01 - ReActor - STATUS - Detected: -54- y.o. Male
00:46:01 - ReActor - STATUS - Swapping Source into Target
00:46:01 - ReActor - STATUS - Restoring the face with CodeFormer (weight: 0.5)
100%|██████████████████████████████████████████████████████████████████████████████████| 15/15 [00:27<00:00,  1.85s/it]
00:46:52 - ReActor - STATUS - Working: source face index [0], target face index [0]
00:46:52 - ReActor - STATUS - Using Hashed Source Face(s) Model...
00:46:52 - ReActor - STATUS - Analyzing Target Image...
00:46:54 - ReActor - STATUS - Detecting Source Face, Index = 0
00:46:54 - ReActor - STATUS - Detected: -58- y.o. Male
00:46:54 - ReActor - STATUS - Detecting Target Face, Index = 0
00:46:54 - ReActor - STATUS - Detected: -41- y.o. Male
00:46:54 - ReActor - STATUS - Swapping Source into Target
00:46:54 - ReActor - STATUS - Restoring the face with CodeFormer (weight: 0.5)
100%|██████████████████████████████████████████████████████████████████████████████████| 15/15 [00:28<00:00,  1.88s/it]
00:47:42 - ReActor - STATUS - Working: source face index [0], target face index [0]
00:47:42 - ReActor - STATUS - Using Hashed Source Face(s) Model...
00:47:42 - ReActor - STATUS - Analyzing Target Image...
00:47:44 - ReActor - STATUS - Detecting Source Face, Index = 0
00:47:44 - ReActor - STATUS - Detected: -58- y.o. Male
00:47:44 - ReActor - STATUS - Detecting Target Face, Index = 0
00:47:44 - ReActor - STATUS - Detected: -47- y.o. Male
00:47:44 - ReActor - STATUS - Swapping Source into Target
00:47:44 - ReActor - STATUS - Restoring the face with CodeFormer (weight: 0.5)
100%|██████████████████████████████████████████████████████████████████████████████████| 15/15 [00:28<00:00,  1.92s/it]
00:48:34 - ReActor - STATUS - Working: source face index [0], target face index [0]
00:48:34 - ReActor - STATUS - Using Hashed Source Face(s) Model...
00:48:34 - ReActor - STATUS - Analyzing Target Image...
00:48:35 - ReActor - STATUS - Detecting Source Face, Index = 0
00:48:35 - ReActor - STATUS - Detected: -58- y.o. Male
00:48:35 - ReActor - STATUS - Detecting Target Face, Index = 0
00:48:35 - ReActor - STATUS - Detected: -42- y.o. Male
00:48:35 - ReActor - STATUS - Swapping Source into Target
00:48:36 - ReActor - STATUS - Restoring the face with CodeFormer (weight: 0.5)
100%|██████████████████████████████████████████████████████████████████████████████████| 15/15 [00:24<00:00,  1.64s/it]
00:49:19 - ReActor - STATUS - Working: source face index [0], target face index [0]
00:49:19 - ReActor - STATUS - Using Hashed Source Face(s) Model...
00:49:19 - ReActor - STATUS - Analyzing Target Image...
00:49:21 - ReActor - STATUS - Detecting Source Face, Index = 0
00:49:21 - ReActor - STATUS - Detected: -58- y.o. Male
00:49:21 - ReActor - STATUS - Detecting Target Face, Index = 0
00:49:21 - ReActor - STATUS - Detected: -43- y.o. Male
00:49:21 - ReActor - STATUS - Swapping Source into Target
00:49:21 - ReActor - STATUS - Restoring the face with CodeFormer (weight: 0.5)
 67%|██████████████████████████████████████████████████████▋                           | 10/15 [00:19<00:09,  1.91s/it]
00:50:03 - ReActor - STATUS - Stopped by User
```


### Additional information

Generation stopped, but RAM keep at full usage:

![Screenshot_5](https://github.com/user-attachments/assets/16d30fc4-0d49-441a-8593-0ab41169061d)

`@echo off

set PYTHON=
set GIT=
set VENV_DIR=
set COMMANDLINE_ARGS=--xformers --api --disable-nan-check --medvram-sdxl

call webui.bat
`