OPTICS.fit leaks memory when called under VS Code's built-in debugger

### Describe the bug

Running clustering algorithm with n_jobs parameter set to more than 1 thread causes memory leak each time algorithm is run.
This simple code causes additional memory leak at each loop cycle. The issue will not occur if i replace manifold reduction algorithm with precomputed features.

### Steps/Code to Reproduce

```python
import gc
import numpy as np
from sklearn.manifold import TSNE
from sklearn.cluster import OPTICS
import psutil
process = psutil.Process()


def main():
    data = np.random.random((100, 100))
    for _i in range(1, 50):
        points = TSNE().fit_transform(data)
        prediction = OPTICS(n_jobs=2).fit_predict(points)  # n_jobs!=1
        points = None
        prediction = None
        del prediction
        del points
        gc.collect()
        print(f"{process.memory_info().rss / 1e6:.1f} MB")


main()
```

### Expected Results

Program's memory usage nearly constant between loop cycles

### Actual Results

Program's memory usage increases infinitely

### Versions

```shell
System:
    python: 3.10.6 (tags/v3.10.6:9c7b4bd, Aug  1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)]
executable: .venv\Scripts\python.exe
   machine: Windows-10-10.0.26100-SP0

Python dependencies:
      sklearn: 1.6.0
          pip: 24.3.1
   setuptools: 63.2.0
        numpy: 1.25.2
        scipy: 1.14.1
       Cython: None
       pandas: 2.2.3
   matplotlib: 3.10.0
       joblib: 1.4.2
threadpoolctl: 3.5.0

Built with OpenMP: True

threadpoolctl info:
       user_api: openmp
   internal_api: openmp
    num_threads: 16
         prefix: vcomp
       filepath: .venv\Lib\site-packages\sklearn\.libs\vcomp140.dll
        version: None

       user_api: blas
   internal_api: openblas
    num_threads: 16
         prefix: libopenblas
       filepath: .venv\Lib\site-packages\numpy\.libs\libopenblas64__v0.3.23-246-g3d31191b-gcc_10_3_0.dll
        version: 0.3.23.dev
threading_layer: pthreads
   architecture: Cooperlake

       user_api: blas
   internal_api: openblas
    num_threads: 16
         prefix: libscipy_openblas
       filepath: .venv\Lib\site-packages\scipy.libs\libscipy_openblas-5b1ec8b915dfb81d11cebc0788069d2d.dll
        version: 0.3.27.dev
threading_layer: pthreads
   architecture: Cooperlake
```

COMMENT:
I tried with the integrated debugger of VS Code under macOS and I got the following:

<details>

```
 /usr/bin/env /Users/ogrisel/miniforge3/envs/dev/bin/python /Users/ogrisel/.vscode/extensions/ms-python.debugpy-2024.12.0-darwin-arm64/bundled/libs/debugpy/adapter/../../debugpy/launcher 65086 -- /Users/ogrisel/tmp/debug_leak.py
223.6 MB
225.4 MB
227.2 MB
228.8 MB
230.4 MB
232.1 MB
233.7 MB
235.3 MB
237.0 MB
238.7 MB
240.3 MB
233.7 MB
229.8 MB
222.5 MB
224.0 MB
225.8 MB
227.3 MB
229.0 MB
230.1 MB
231.7 MB
233.1 MB
236.1 MB
237.6 MB
239.6 MB
241.1 MB
242.8 MB
244.5 MB
246.1 MB
248.0 MB
249.8 MB
251.4 MB
253.1 MB
254.7 MB
256.4 MB
258.0 MB
259.7 MB
261.3 MB
263.0 MB
266.4 MB
267.9 MB
257.7 MB
258.8 MB
260.7 MB
266.2 MB
265.3 MB
267.0 MB
268.6 MB
270.3 MB
272.0 MB
```

</details>

So it seems to go up by nearly 2 MB per iteration but sometimes goes down by quite a lot, so I doubt that this is a real leak.

And the fact that it does not happen when running using a regular Python interpreter makes me think that it's not a bug in scikit-learn but rather in the debugger itself (if it is actually a bug).

Labels: Bug, Performance, Needs Investigation