Kitware / trame

Trame lets you weave various components and technologies into a Web Application solely written in Python.
https://kitware.github.io/trame/
Other
406 stars 54 forks source link

Memory leak on Ubuntu #387

Closed Jupihawx closed 8 months ago

Jupihawx commented 9 months ago

When I move the view on a simple trame+pyvista view, the memory fills up. Moving the view quickly for long enough makes my whole system freeze. Same happens if I have an animation with the colors changing with time for example.

Steps to reproduce the behavior:

  1. Launch the first example : https://tutorial.pyvista.org/tutorial/09_trame/a_trame_simple.html
  2. Move the view around while inspecting the machine's RAM

Code

import pyvista as pv
from pyvista import examples
from pyvista.trame.ui import plotter_ui
from trame.app import get_server
from trame.ui.vuetify import SinglePageLayout

pv.OFF_SCREEN = True

server = get_server()
state, ctrl = server.state, server.controller

mesh = examples.load_random_hills()

pl = pv.Plotter()
pl.add_mesh(mesh)

with SinglePageLayout(server) as layout:
    with layout.content:
        view = plotter_ui(pl)

server.start()

Expected behavior

The Ram should not increase

Platform: Linux MINT

Device:

OS:

Browsers Affected:

jourdain commented 9 months ago

Thanks for the report. We'll look into that.

jourdain commented 9 months ago

I tried the following setup and could not find something obvious. Can you provide more information on your setup that could differ from my test?

Tested on macOS

Using Chrome I see the memory grow and shrink when GC comes around. While the memory usage of the browser is not negligible, it remains bounded.

Tested server on Ubuntu and client on macOS

Starting the server process using regular VTK (X not OSMesa) on my linux. Connecting to that server with my mac using Chrome and Firefox. I see the same behavior with Chrome as before, while Firefox uses much more memory, but after a while that memory get freed and see similar up/down memory usage.

Tested on ubuntu (client+server)

I tested Firefox on Linux directly and saw the same behavior of memory increase, but that gets garbage collected, and the overall memory remains bounded.


Was it with regular VTK or with vtk-osmesa?

jourdain commented 9 months ago

Was the memory used at the browser level or the server?

jourdain commented 9 months ago

Tested environment

Package            Version
------------------ ----------
aiohttp            3.9.1
aiosignal          1.3.1
async-timeout      4.0.3
attrs              23.1.0
certifi            2023.11.17
charset-normalizer 3.3.2
contourpy          1.2.0
cycler             0.12.1
fonttools          4.46.0
frozenlist         1.4.0
idna               3.6
kiwisolver         1.4.5
matplotlib         3.8.2
more-itertools     10.1.0
multidict          6.0.4
numpy              1.26.2
packaging          23.2
Pillow             10.1.0
pip                23.3.1
platformdirs       4.1.0
pooch              1.8.0
pyparsing          3.1.1
python-dateutil    2.8.2
pyvista            0.43.0
requests           2.31.0
scooby             0.9.2
setuptools         59.6.0
six                1.16.0
trame              3.4.0
trame-client       2.14.1
trame-server       2.13.1
trame-vtk          2.6.2
trame-vuetify      2.3.1
urllib3            2.1.0
vtk                9.3.0
wslink             1.12.4
yarl               1.9.4
Jupihawx commented 9 months ago

After more testing, it seems that the issue does not arise if I make a clean new venv. But does happen on my client+server machine with the following env:

Package                      Version                Editable project location
---------------------------- ---------------------- ----------------------------------------
absl-py                      1.3.0
addict                       2.4.0
aiohttp                      3.8.3
aiosignal                    1.3.1
altgraph                     0.17.3
anyio                        3.6.2
appdirs                      1.4.4
apt-clone                    0.2.1
apturl                       0.5.2
argon2-cffi                  21.3.0
argon2-cffi-bindings         21.2.0
asttokens                    2.0.8
astunparse                   1.6.3
async-timeout                4.0.2
attrs                        22.1.0
autobahn                     21.11.1
Automat                      20.2.0
Babel                        2.10.3
backcall                     0.2.0
base58                       1.0.3
bcrypt                       3.2.0
beautifulsoup4               4.10.0
beniget                      0.4.1
bleach                       5.0.1
blinker                      1.6.2
bokeh                        3.2.2
Brlapi                       0.8.3
Brotli                       1.0.9
cachetools                   5.2.1
cbor                         1.0.0
certifi                      2020.6.20
cfclient                     2022.12.post21+7551e8c /home/boris/crazyflie-clients-python/src
cffi                         1.15.1
cflib                        0.1.21                 /home/boris/crazyflie-lib-python
cftime                       1.6.2
chardet                      4.0.0
charset-normalizer           2.1.1
click                        8.1.3
cloudpickle                  2.2.0
cmocean                      3.0.3
colorama                     0.4.4
colorcet                     3.0.1
command-not-found            0.3
commonmark                   0.9.1
ConfigArgParse               1.5.3
configobj                    5.0.6
constantly                   15.1.0
contourpy                    1.1.0
cryptography                 3.4.8
cupshelpers                  1.0
customtkinter                5.0.3
cycler                       0.11.0
Cython                       0.29.28
darkdetect                   0.8.0
dash                         2.9.3
dash-core-components         2.0.0
dash-html-components         2.0.0
dash-table                   5.0.0
dbus-python                  1.2.18
debugpy                      1.6.3
decorator                    5.1.1
defer                        1.0.6
defusedxml                   0.7.1
distro                       1.7.0
dlib                         19.16.0
dnspython                    2.3.0
docker                       5.0.3
docker-compose               1.29.2
dockerpty                    0.4.1
docopt                       0.6.2
ecdsa                        0.18.0b1
entrypoints                  0.4
et-xmlfile                   1.1.0
exceptiongroup               1.1.1
executing                    1.1.1
eyeD3                        0.8.10
fastjsonschema               2.16.2
filelock                     3.6.0
Flask                        2.3.2
flatbuffers                  23.1.4
fluidfoam                    0.2.3
fonttools                    4.29.1
freetype-py                  2.3.0
frozenlist                   1.3.3
fs                           2.4.12
fsspec                       2023.3.0
future                       0.18.2
gast                         0.4.0
google-auth                  2.15.0
google-auth-oauthlib         0.4.6
google-pasta                 0.2.0
graphviz                     0.20.1
grpcio                       1.53.0
gym                          0.21.0
gym-notices                  0.0.8
gyp                          0.1
h5py                         3.7.0
hsluv                        5.0.3
html5lib                     1.1
httplib2                     0.20.2
hyperlink                    21.0.0
hyperopt                     0.2.7
idna                         3.3
ifaddr                       0.1.7
imageio                      2.22.4
imageio-ffmpeg               0.4.8
IMDbPY                       2021.4.18
importlib-metadata           4.13.0
incremental                  21.3.0
iniconfig                    2.0.0
ipycanvas                    0.13.1
ipydatawidgets               4.3.5
ipyevents                    2.0.2
ipykernel                    6.16.1
ipympl                       0.9.3
ipython                      8.5.0
ipython-genutils             0.2.0
ipyvtklink                   0.2.2
ipywidgets                   8.0.5
itsdangerous                 2.1.2
jax                          0.4.7
jedi                         0.18.1
jeepney                      0.7.1
Jinja2                       3.1.2
joblib                       1.2.0
json5                        0.9.10
jsonschema                   4.16.0
jupyter_client               7.4.3
jupyter_core                 4.11.2
jupyter-server               1.21.0
jupyter_server_proxy         4.0.0
jupyterlab                   3.4.8
jupyterlab-pygments          0.2.2
jupyterlab_server            2.16.1
jupyterlab-widgets           3.0.6
kazam                        1.4.5
keras                        2.12.0
keyring                      23.5.0
kiwisolver                   1.3.2
launchpadlib                 1.10.16
lazr.restfulclient           0.14.4
lazr.uri                     1.0.6
libclang                     15.0.3
libusb-package               1.0.26.1
lic                          0.4.5
lightning-utilities          0.8.0
linkify-it-py                2.0.2
llvmlite                     0.39.1
louis                        3.20.0
lxml                         4.8.0
lz4                          3.1.3+dfsg
macaroonbakery               1.3.1
Mako                         1.1.3
Markdown                     3.4.1
markdown-it-py               3.0.0
MarkupSafe                   2.1.1
matplotlib                   3.5.1
matplotlib-inline            0.1.6
mdit-py-plugins              0.4.0
mdurl                        0.1.2
meshio                       5.3.4
meson                        0.61.2
mistune                      2.0.4
ml-dtypes                    0.0.4
mnemonic                     0.19
more-itertools               8.10.0
MouseInfo                    0.1.3
mpi4py                       3.1.3
mpmath                       0.0.0
msgpack                      1.0.3
multidict                    6.0.3
nbclassic                    0.4.5
nbclient                     0.7.0
nbconvert                    7.2.2
nbformat                     5.7.0
nemo-emblems                 5.4.1
nest-asyncio                 1.5.6
netaddr                      0.8.0
netCDF4                      1.6.2
netifaces                    0.11.0
networkx                     1.11
notebook                     6.5.1
notebook_shim                0.2.0
numba                        0.56.4
numpy                        1.22.4
numpy-stl                    3.0.0
nvidia-cublas-cu11           11.10.3.66
nvidia-cuda-nvrtc-cu11       11.7.99
nvidia-cuda-runtime-cu11     11.7.99
nvidia-cudnn-cu11            8.6.0.163
oauthlib                     3.2.0
Ofpp                         0.11
onboard                      1.4.1
open3d                       0.17.0
opencv-python                4.6.0.66
openpyxl                     3.1.2
opt-einsum                   3.3.0
packaging                    21.3
PAM                          0.4.2
pandas                       2.0.3
pandocfilters                1.5.0
panel                        1.2.1
param                        1.13.0
parso                        0.8.3
passlib                      1.7.4
pexpect                      4.8.0
phiflow                      3.0.0
phiml                        1.3.1
pickleshare                  0.7.5
Pillow                       9.5.0
pip                          23.0.1
pipreqs                      0.4.11
plotly                       5.14.1
pluggy                       1.0.0
ply                          3.11
pooch                        1.6.0
prometheus-client            0.15.0
prompt-toolkit               3.0.31
protobuf                     4.22.1
psutil                       5.9.0
ptyprocess                   0.7.0
pure-eval                    0.2.2
py-ubjson                    0.16.1
py4j                         0.10.9.7
pyarrow                      10.0.1
pyasn1                       0.4.8
pyasn1-modules               0.2.1
PyAutoGUI                    0.9.53
pycairo                      1.20.1
pycparser                    2.21
pyct                         0.5.0
pycups                       2.0.1
pycurl                       7.44.1
pyelftools                   0.27
PyFoam                       2022.9
pygem                        2.0.0
PyGetWindow                  0.0.9
Pygments                     2.13.0
PyGObject                    3.42.1
PyHamcrest                   2.0.2
PyICU                        2.8.1
pyinotify                    0.9.6
pyinstaller                  5.13.2
pyinstaller-hooks-contrib    2023.3
PyJWT                        2.3.0
pymacaroons                  0.13.0
pymesh                       1.0.2
pymongo                      4.3.3
PyMsgBox                     1.0.9
PyNaCl                       1.5.0
pyntcloud                    0.3.1
pyOpenSSL                    21.0.0
pyparsing                    2.4.7
pyparted                     3.11.7
pyperclip                    1.8.2
pypng                        0.0.20
PyQRCode                     1.2.1
PyQt5                        5.15.9
PyQt5-Qt5                    5.15.2
PyQt5-sip                    12.11.1
pyqtgraph                    0.13.1
pyquaternion                 0.9.9
PyRect                       0.2.0
pyRFC3339                    1.1
pyrsistent                   0.18.1
PyScreeze                    0.1.28
pyserial                     3.5
pytest                       7.3.1
python-apt                   2.4.0+ubuntu2
python-dateutil              2.8.2
python-debian                0.1.43+ubuntu1.1
python-dotenv                0.19.2
python-Levenshtein           0.12.2
python-magic                 0.4.24
python-snappy                0.5.3
python-utils                 3.4.5
python-vlc                   3.0.18121
python-xapp                  2.2.2
python-xlib                  0.29
python3-xlib                 0.15
pythran                      0.10.0
pythreejs                    2.4.2
pytorch-lightning            1.2.6
PyTrie                       0.4.0
pyts                         0.12.0
pytweening                   1.0.4
pytz                         2022.1
pyusb                        1.2.1
pyvista                      0.39.1
pyvistaqt                    0.10.0
pyviz_comms                  3.0.0
pyxdg                        0.27
PyYAML                       6.0
pyzmq                        25.1.1
qasync                       0.23.0
qtm                          2.1.1
QtPy                         2.3.1
reportlab                    3.6.8
requests                     2.25.1
requests-file                1.5.1
requests-oauthlib            1.3.1
rich                         12.6.0
rsa                          4.9
scikit-learn                 1.1.3
scipy                        1.11.2
scooby                       0.7.0
screen-resolution-extra      0.0.0
seaborn                      0.12.2
SecretStorage                3.3.1
Send2Trash                   1.8.0
service-identity             18.1.0
setproctitle                 1.2.2
setuptools                   59.6.0
simpervisor                  1.0.0
six                          1.16.0
sklearn                      0.0.post1
smithers                     0.0.1
smolyak                      0.0.1
smop                         0.41b0
snakeviz                     2.1.1
sniffio                      1.3.0
sortedcontainers             2.1.0
soupsieve                    2.3.1
stable-baselines3            1.7.0
stack-data                   0.5.1
sympy                        1.9
systemd-python               234
tenacity                     8.2.2
tensorboard                  2.12.0
tensorboard-data-server      0.7.0
tensorboard-plugin-wit       1.8.1
tensorflow                   2.12.0
tensorflow-estimator         2.12.0
tensorflow-io-gcs-filesystem 0.29.0
termcolor                    2.2.0
terminado                    0.16.0
texttable                    1.6.4
threadpoolctl                3.1.0
tinycss2                     1.1.1
tldextract                   3.1.2
tomli                        2.0.1
torch                        1.13.1+cu116
torch-tb-profiler            0.4.1
torchaudio                   0.13.1+cu116
torchinfo                    1.8.0
torchmetrics                 0.11.4
torchsummary                 1.5.1
torchvision                  0.14.1+cu116
tornado                      6.2
tqdm                         4.64.1
traitlets                    5.5.0
traittypes                   0.2.1
trame                        3.4.0
trame-client                 2.14.1
trame-components             2.1.1
trame-deckgl                 2.0.2
trame-markdown               2.0.2
trame-matplotlib             2.0.2
trame-plotly                 2.1.1
trame-rca                    0.3.1
trame-router                 2.0.2
trame-server                 2.13.1
trame-simput                 2.3.2
trame-vega                   2.0.3
trame-vtk                    2.6.2
trame-vuetify                2.3.1
Twisted                      22.1.0
txaio                        21.2.1
typing_extensions            4.4.0
tzdata                       2023.3
u-msgpack-python             2.3.0
ubuntu-drivers-common        0.0.0
uc-micro-py                  1.0.2
ufoLib2                      0.13.1
ufw                          0.36.1
ujson                        5.1.0
ulauncher                    5.15.6
unicodedata2                 14.0.0
Unidecode                    1.3.3
urllib3                      1.26.5
vboxapi                      1.0
vispy                        0.9.6
vtk                          9.2.2
wadllib                      1.3.6
watchdog                     2.1.9
wcwidth                      0.2.5
webencodings                 0.5.1
websocket-client             1.4.1
Werkzeug                     2.3.4
wheel                        0.37.1
widgetsnbextension           4.0.6
wrapt                        1.14.1
wsaccel                      0.6.3
wslink                       1.12.4
xdg                          5
xkit                         0.0.0
xlrd                         1.2.0
xyzservices                  2023.7.0
yarg                         0.1.9
yarl                         1.8.2
youtube-dl                   2021.12.17
zipp                         1.0.0
zope.interface               5.4.0

The issue is probably from my side only then.. I made a small clip to show the behaviour: https://imgur.com/a/xqIsOKH

jourdain commented 9 months ago

Try updating your vtk as I remember a memory leak was fixed in the image encoder a while back and since 9.2.2 was released in October 2022 it could be in that version (just don't remember).