Repository: stable-diffusion-webui
Issue: [Bug]: Multiple Instances of python -u launch.py using up RAM
Labels: bug-report

### Is there an existing issue for this?

- [X] I have searched the existing issues and checked the recent builds/commits

### What happened?

Right after launching webui, I notice my systems Physical RAM (not VRAM) is being used up more and more the longer I run the application and use it.  If I check htop I find there are many separate python processes running launch.py. 

Is this expected? Is anyone else seeing this? 

Immediately after laucnhing webui:
![image](https://github.com/AUTOMATIC1111/stable-diffusion-webui/assets/24832561/63bf0658-cff6-4a50-b229-e582a5c28a1d)

After using the application for a while:
![image](https://github.com/AUTOMATIC1111/stable-diffusion-webui/assets/24832561/f4ccf916-861b-4950-87f2-f12c575677bb)


### Steps to reproduce the problem

1. Launch webui.sh 
2. generate a few images
3. change models and generate more images
4. change models again and generate more images
5. check resource usage with htop command

### What should have happened?

I would not expect there to be multiple instances of launch.py running. I wonder if there is something in the background causing this. I have 64GB of RAM and after heavy use I have seen up to 43 GB being used up ny the webui. If I CTRL-C in the console, the memory is freed up and available to my system again. 

### Sysinfo

[sysinfo-2023-09-11-19-35.txt](https://github.com/AUTOMATIC1111/stable-diffusion-webui/files/12579754/sysinfo-2023-09-11-19-35.txt)


### What browsers do you use to access the UI ?

Firefox 117.0

### Console logs

```Shell
(StableDiffusion)    stable-diffusion-webui   git:(master) ✗ ./webui.sh

################################################################
Install script for stable-diffusion + Web UI
Tested on Debian 11 (Bullseye)
################################################################

################################################################
Running on tokenwizard user
################################################################

################################################################
Repo already cloned, using it as install directory
################################################################

################################################################
python venv already activate or run without venv: /home/tokenwizard/stable-diffusion/stable-diffusion-webui/venv
################################################################

################################################################
Launching launch.py...
################################################################
Python 3.10.10 (main, Mar  5 2023, 22:26:53) [GCC 12.2.1 20230201]
Version: v1.6.0
Commit hash: 5ef669de080814067961f28357256e8fe27544f4
Faceswaplab : Use GPU requirements
Checking faceswaplab requirements
0.0017266059994653915
Launching Web UI with arguments: --xformers --listen --port 9091 --gradio-auth tokenwizard:<<<redacted>>> --enable-insecure-extension-access
2023-09-11 15:23:28,859 - ControlNet - INFO - ControlNet v1.1.401
ControlNet preprocessor location: /home/tokenwizard/stable-diffusion/stable-diffusion-webui/extensions/sd-webui-controlnet/annotator/downloads
2023-09-11 15:23:28,949 - ControlNet - INFO - ControlNet v1.1.401
Loading weights [15012c538f] from /home/tokenwizard/stable-diffusion/stable-diffusion-webui/models/Stable-diffusion/1.0 - realisticVisionV51_v51VAE.safetensors
/home/tokenwizard/stable-diffusion/stable-diffusion-webui/modules/gradio_extensons.py:25: GradioDeprecationWarning: `optional` parameter is deprecated, and it has no effect
  res = original_IOComponent_init(self, *args, **kwargs)
/home/tokenwizard/stable-diffusion/stable-diffusion-webui/modules/gradio_extensons.py:25: GradioUnusedKwargWarning: You have unused kwarg parameters in Checkbox, please remove them: {'placeholder': 'enable'}
  res = original_IOComponent_init(self, *args, **kwargs)
/home/tokenwizard/stable-diffusion/stable-diffusion-webui/modules/gradio_extensons.py:25: GradioUnusedKwargWarning: You have unused kwarg parameters in Checkbox, please remove them: {'placeholder': 'Blend Faces'}
  res = original_IOComponent_init(self, *args, **kwargs)
/home/tokenwizard/stable-diffusion/stable-diffusion-webui/modules/gradio_extensons.py:25: GradioUnusedKwargWarning: You have unused kwarg parameters in Checkbox, please remove them: {'placeholder': 'Same Gender'}
  res = original_IOComponent_init(self, *args, **kwargs)
/home/tokenwizard/stable-diffusion/stable-diffusion-webui/modules/gradio_extensons.py:25: GradioUnusedKwargWarning: You have unused kwarg parameters in Checkbox, please remove them: {'placeholder': 'Sort by size'}
  res = original_IOComponent_init(self, *args, **kwargs)
/home/tokenwizard/stable-diffusion/stable-diffusion-webui/modules/gradio_extensons.py:25: GradioUnusedKwargWarning: You have unused kwarg parameters in Number, please remove them: {'placeholder': 'Which face to get from reference image start from 0'}
  res = original_IOComponent_init(self, *args, **kwargs)
/home/tokenwizard/stable-diffusion/stable-diffusion-webui/modules/gradio_extensons.py:25: GradioUnusedKwargWarning: You have unused kwarg parameters in Checkbox, please remove them: {'placeholder': 'Swap face in source image'}
  res = original_IOComponent_init(self, *args, **kwargs)
/home/tokenwizard/stable-diffusion/stable-diffusion-webui/modules/gradio_extensons.py:25: GradioUnusedKwargWarning: You have unused kwarg parameters in Checkbox, please remove them: {'placeholder': 'Swap face in generated image'}
  res = original_IOComponent_init(self, *args, **kwargs)
/home/tokenwizard/stable-diffusion/stable-diffusion-webui/modules/gradio_extensons.py:25: GradioUnusedKwargWarning: You have unused kwarg parameters in Checkbox, please remove them: {'placeholder': 'discard'}
  res = original_IOComponent_init(self, *args, **kwargs)
/home/tokenwizard/stable-diffusion/stable-diffusion-webui/modules/gradio_extensons.py:25: GradioUnusedKwargWarning: You have unused kwarg parameters in Dropdown, please remove them: {'default': 'Current'}
  res = original_IOComponent_init(self, *args, **kwargs)
/home/tokenwizard/stable-diffusion/stable-diffusion-webui/modules/gradio_extensons.py:25: GradioUnusedKwargWarning: You have unused kwarg parameters in Checkbox, please remove them: {'placeholder': 'overwrite'}
  res = original_IOComponent_init(self, *args, **kwargs)
Running on local URL:  http://0.0.0.0:9091

To create a public link, set `share=True` in `launch()`.
Startup time: 6.8s (prepare environment: 1.5s, import torch: 1.7s, import gradio: 0.6s, setup paths: 0.5s, initialize shared: 0.1s, other imports: 0.3s, load scripts: 1.1s, create ui: 0.6s, gradio launch: 0.1s).
Creating model from config: /home/tokenwizard/stable-diffusion/stable-diffusion-webui/configs/v1-inference.yaml
Applying attention optimization: xformers... done.
Model loaded in 1.9s (load weights from disk: 0.9s, create model: 0.3s, apply weights to model: 0.6s).
2023-09-11 15:26:47,242 - ControlNet - INFO - ControlNet Hooked - Time = 9.822845458984375e-05
100%|███████████████████████████████████████████████████████████████████████████████████| 75/75 [00:06<00:00, 11.74it/s]
Total progress: 100%|███████████████████████████████████████████████████████████████████| 75/75 [00:06<00:00, 11.25it/s]
2023-09-11 15:27:03,403 - ControlNet - INFO - ControlNet Hooked - Time = 7.700920104980469e-055 [00:06<00:00, 12.18it/s]
100%|███████████████████████████████████████████████████████████████████████████████████| 75/75 [00:06<00:00, 12.11it/s]
Total progress: 100%|███████████████████████████████████████████████████████████████████| 75/75 [00:06<00:00, 11.82it/s]
2023-09-11 15:27:14,977 - ControlNet - INFO - ControlNet Hooked - Time = 6.937980651855469e-055 [00:06<00:00, 12.09it/s]
100%|███████████████████████████████████████████████████████████████████████████████████| 75/75 [00:06<00:00, 11.99it/s]
2023-09-11 15:27:21,480 - ControlNet - INFO - ControlNet Hooked - Time = 6.961822509765625e-050 [00:06<00:18, 11.91it/s]
100%|███████████████████████████████████████████████████████████████████████████████████| 75/75 [00:06<00:00, 12.17it/s]
2023-09-11 15:27:27,887 - ControlNet - INFO - ControlNet Hooked - Time = 6.866455078125e-05/300 [00:12<00:12, 12.20it/s]
100%|███████████████████████████████████████████████████████████████████████████████████| 75/75 [00:06<00:00, 12.00it/s]
2023-09-11 15:27:34,389 - ControlNet - INFO - ControlNet Hooked - Time = 6.699562072753906e-050 [00:19<00:06, 11.97it/s]
100%|███████████████████████████████████████████████████████████████████████████████████| 75/75 [00:06<00:00, 12.07it/s]
Total progress: 100%|█████████████████████████████████████████████████████████████████| 300/300 [00:26<00:00, 11.46it/s]
Reusing loaded model 1.0 - realisticVisionV51_v51VAE.safetensors [15012c538f] to load anything-v3-fp16-pruned.safetensors [d1facd9a2b]
Loading weights [d1facd9a2b] from /home/tokenwizard/stable-diffusion/stable-diffusion-webui/models/Stable-diffusion/anything-v3-fp16-pruned.safetensors
Applying attention optimization: xformers... done.
Weights loaded in 1.6s (send model to cpu: 0.7s, load weights from disk: 0.2s, apply weights to model: 0.3s, move model to device: 0.4s).
2023-09-11 15:28:25,610 - ControlNet - INFO - ControlNet Hooked - Time = 6.628036499023438e-05
100%|███████████████████████████████████████████████████████████████████████████████████| 75/75 [00:06<00:00, 12.11it/s]
2023-09-11 15:28:32,060 - ControlNet - INFO - ControlNet Hooked - Time = 7.557868957519531e-050 [00:06<00:18, 12.15it/s]
100%|███████████████████████████████████████████████████████████████████████████████████| 75/75 [00:06<00:00, 12.18it/s]
2023-09-11 15:28:38,439 - ControlNet - INFO - ControlNet Hooked - Time = 7.224082946777344e-050 [00:12<00:12, 12.11it/s]
100%|███████████████████████████████████████████████████████████████████████████████████| 75/75 [00:06<00:00, 12.05it/s]
2023-09-11 15:28:44,900 - ControlNet - INFO - ControlNet Hooked - Time = 6.961822509765625e-050 [00:18<00:06, 12.11it/s]
100%|███████████████████████████████████████████████████████████████████████████████████| 75/75 [00:06<00:00, 12.16it/s]
Total progress: 100%|█████████████████████████████████████████████████████████████████| 300/300 [00:25<00:00, 11.57it/s]
Reusing loaded model anything-v3-fp16-pruned.safetensors [d1facd9a2b] to load icbinpICantBelieveIts_seco.safetensors [fa1224c923]
Loading weights [fa1224c923] from /home/tokenwizard/stable-diffusion/stable-diffusion-webui/models/Stable-diffusion/icbinpICantBelieveIts_seco.safetensors
Applying attention optimization: xformers... done.
Weights loaded in 7.0s (send model to cpu: 0.7s, load weights from disk: 0.6s, apply weights to model: 5.2s, move model to device: 0.4s).
2023-09-11 15:33:04,964 - ControlNet - INFO - ControlNet Hooked - Time = 6.413459777832031e-05
100%|███████████████████████████████████████████████████████████████████████████████████| 75/75 [00:06<00:00, 12.13it/s]
2023-09-11 15:33:11,400 - ControlNet - INFO - ControlNet Hooked - Time = 6.985664367675781e-050 [00:06<00:18, 12.00it/s]
100%|███████████████████████████████████████████████████████████████████████████████████| 75/75 [00:06<00:00, 12.10it/s]
2023-09-11 15:33:17,845 - ControlNet - INFO - ControlNet Hooked - Time = 7.271766662597656e-050 [00:12<00:12, 12.28it/s]
100%|███████████████████████████████████████████████████████████████████████████████████| 75/75 [00:06<00:00, 12.13it/s]
2023-09-11 15:33:24,286 - ControlNet - INFO - ControlNet Hooked - Time = 7.367134094238281e-050 [00:18<00:06, 12.11it/s]
100%|███████████████████████████████████████████████████████████████████████████████████| 75/75 [00:06<00:00, 12.23it/s]
Total progress: 100%|█████████████████████████████████████████████████████████████████| 300/300 [00:25<00:00, 11.55it/s]
Reusing loaded model icbinpICantBelieveIts_seco.safetensors [fa1224c923] to load clarity_3.safetensors [0ba3d23162]it/s]
Loading weights [0ba3d23162] from /home/tokenwizard/stable-diffusion/stable-diffusion-webui/models/Stable-diffusion/clarity_3.safetensors
Applying attention optimization: xformers... done.
Weights loaded in 7.2s (send model to cpu: 0.7s, load weights from disk: 0.6s, apply weights to model: 5.4s, move model to device: 0.4s).
2023-09-11 15:33:47,312 - ControlNet - INFO - ControlNet Hooked - Time = 7.367134094238281e-05
100%|███████████████████████████████████████████████████████████████████████████████████| 75/75 [00:06<00:00, 12.14it/s]
2023-09-11 15:33:53,751 - ControlNet - INFO - ControlNet Hooked - Time = 6.985664367675781e-050 [00:06<00:18, 12.09it/s]
100%|███████████████████████████████████████████████████████████████████████████████████| 75/75 [00:06<00:00, 12.16it/s]
2023-09-11 15:34:00,157 - ControlNet - INFO - ControlNet Hooked - Time = 6.723403930664062e-050 [00:12<00:12, 12.07it/s]
100%|███████████████████████████████████████████████████████████████████████████████████| 75/75 [00:06<00:00, 12.07it/s]
2023-09-11 15:34:06,607 - ControlNet - INFO - ControlNet Hooked - Time = 6.67572021484375e-0500 [00:18<00:06, 12.14it/s]
100%|███████████████████████████████████████████████████████████████████████████████████| 75/75 [00:06<00:00, 12.16it/s]
Total progress: 100%|█████████████████████████████████████████████████████████████████| 300/300 [00:25<00:00, 11.57it/s]
Total progress: 100%|█████████████████████████████████████████████████████████████████| 300/300 [00:25<00:00, 12.26it/s]
```


### Additional information

I'm not sure if this is a bug or by design, but I'm unsure why we would need so many separate processes of python. 
I assume this is not actually showing that each process is using the stated amount of RAM because that would total up to much more that what I have installed.