tillahoffmann / obsidian-jupyter

MIT License
439 stars 23 forks source link

Memory Leak #64

Closed Remy2701 closed 1 year ago

Remy2701 commented 1 year ago

There seems to be a memory leak with the output of the python code, I noticed it when plotting graphs, my ram usage would be abnormally high. I guess the problem comes from the fact that the memory allocated for those graphs is never cleaned up even after pressing the run button again or even closing the page.

Console Output Here is the output of the console (even though I don't think it'll give much information)

app.js:1 Obsidian Developer Console
plugin:obsidian-icon-shortcodes:139 loading Icon Shortcodes
plugin:obsidian-icons-plugin:26240 loading plugin
plugin:metaedit:5434 Loading MetaEdit
plugin:metaedit:5191 MetaEdit: (LOG) automator of type 'KanbanHelper' does not exist.
plugin:metaedit:5191 MetaEdit: (LOG) automator of type 'ProgressProperties' does not exist.
plugin:obsidian-admonition:479 Obsidian Admonition loaded
plugin:dataview:19396 Dataview: version 0.5.55 (requires obsidian 0.13.11)
plugin:card-board:1 loading CardBoard plugin
plugin:mousewheel-image-zoom:239 Loaded: Mousewheel image zoom
plugin:editing-toolbar:9 cMenuToolbar v2.3.1 loaded
plugin:table-editor-obsidian:23712 loading markdown-table-editor plugin
plugin:link-favicon:9 enabling plugin: link favicons
plugin:quick-latex:1422 loading Quick-Latex plugin
plugin:obsidian-jupyter:3229 loading jupyter plugin
plugin:obsidian-jupyter:3247 python script exists at /home/remy/Documents/Brain/.obsidian/plugins/obsidian-jupyter/obsidian-jupyter.py
plugin:make-md:49872 Loading Make.md: 167.195068359375 ms
plugin:make-md:20155 Reindex Spaces Data: 11.6201171875 ms
plugin:obsidian-jupyter:3172 Uncaught (in promise) TypeError: Cannot read properties of null (reading 'view')
    at JupyterPlugin.eval (plugin:obsidian-jupyter:3172:129)
    at Generator.next (<anonymous>)
    at eval (plugin:obsidian-jupyter:56:71)
    at new Promise (<anonymous>)
    at __awaiter$1 (plugin:obsidian-jupyter:52:12)
    at JupyterPlugin.postprocessor (plugin:obsidian-jupyter:3170:16)
    at t.render (app.js:1:1439138)
    at enter (app.js:1:1450410)
    at e.iterate (app.js:1:504974)
    at Xc.iterate (app.js:1:1065117)
plugin:obsidian-jupyter:3172 Uncaught (in promise) TypeError: Cannot read properties of null (reading 'view')
    at JupyterPlugin.eval (plugin:obsidian-jupyter:3172:129)
    at Generator.next (<anonymous>)
    at eval (plugin:obsidian-jupyter:56:71)
    at new Promise (<anonymous>)
    at __awaiter$1 (plugin:obsidian-jupyter:52:12)
    at JupyterPlugin.postprocessor (plugin:obsidian-jupyter:3170:16)
    at t.render (app.js:1:1439138)
    at enter (app.js:1:1450410)
    at e.iterate (app.js:1:504974)
    at Xc.iterate (app.js:1:1065117)
plugin:dataview:12571 Dataview: all 72 files have been indexed in 0.675s (72 cached, 0 skipped).
plugin:obsidian-jupyter:3220 created new client for doc 09838c37cf2c313f using interpreter /usr/bin/python
plugin:obsidian-jupyter:3146 INFO:obsidian-jupyter:started server for document 09838c37cf2c313f

plugin:obsidian-jupyter:3146 INFO:obsidian-jupyter:received request: {"id":"64f2daa9-1a99-4eb0-b436-507d24b5f7fd","body":{"command":"execute","source":"\nimport numpy as np\nfrom matplotlib import pyplot as plt\n\naa_threshold = 0.2 # 20% of radius\n\ndef circle2d_sdf(x, r):\n\treturn np.clip((np.abs(x) - r) / r, 0, aa_threshold) / aa_threshold\n\nx = np.linspace(-1, 1, 1000)\ny = circle2d_sdf(x, 0.5)\n\nplt.plot(x, y)"}}

plugin:obsidian-jupyter:3146 0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.

plugin:obsidian-jupyter:3146 0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.

plugin:obsidian-jupyter:3146 INFO:traitlets:Executing notebook with kernel: 

plugin:obsidian-jupyter:3135 received response Objectbody: "<div class=\"cell border-box-sizing code_cell renid: "64f2daa9-1a99-4eb0-b436-507d24b5f7fd"[[Prototype]]: Objectconstructor: ƒ Object()hasOwnProperty: ƒ hasOwnProperty()isPrototypeOf: ƒ isPrototypeOf()propertyIsEnumerable: ƒ propertyIsEnumerable()toLocaleString: ƒ toLocaleString()toString: ƒ toString()valueOf: ƒ valueOf()__defineGetter__: ƒ __defineGetter__()__defineSetter__: ƒ __defineSetter__()__lookupGetter__: ƒ __lookupGetter__()__lookupSetter__: ƒ __lookupSetter__()__proto__: (...)get __proto__: ƒ __proto__()set __proto__: ƒ __proto__()
plugin:obsidian-jupyter:3146 INFO:obsidian-jupyter:sent response: {"id": "64f2daa9-1a99-4eb0-b436-507d24b5f7fd", "body": "<div class=\"cell border-box-sizing code_cell rendered\">\n<div class=\"input\">\n<div class=\"prompt input_prompt\">In&nbsp;[1]:</div>\n<div class=\"inner_cell\">\n    <div class=\"input_area\">\n<div class=\" highlight hl-ipython3\"><pre><span></span><span class=\"kn\">import</span> <span class=\"nn\">numpy</span> <span class=\"k\">as</span> <span class=\"nn\">np</span>\n<span class=\"kn\">from</span> <span class=\"nn\">matplotlib</span> <span class=\"kn\">import</span> <span class=\"n\">pyplot</span> <span class=\"k\">as</span> <span class=\"n\">plt</span>\n\n<span class=\"n\">aa_threshold</span> <span class=\"o\">=</span> <span class=\"mf\">0.2</span> <span class=\"c1\"># 20% of radius</span>\n\n<span class=\"k\">def</span> <span class=\"nf\">circle2d_sdf</span><span class=\"p\">(</span><span class=\"n\">x</span><span class=\"p\">,</span> <span class=\"n\">r</span><span class=\"p\">):</span>\n\t<span class=\"k\">return</span> <span class=\"n\">np</span><span class=\"o\">.</span><span class=\"n\">clip</span><span class=\"p\">((</span><span class=\"n\">np</span><span class=\"o\">.</span><span class=\"n\">abs</span><span class=\"p\">(</span><span class=\"n\">x</span><span class=\"p\">)</span> <span class=\"o\">-</span> <span class=\"n\">r</span><span class=\"p\">)</span> <span class=\"o\">/</span> <span class=\"n\">r</span><span class=\"p\">,</span> <span class=\"mi\">0</span><span class=\"p\">,</span> <span class=\"n\">aa_threshold</span><span class=\"p\">)</span> <span class=\"o\">/</span> <span class=\"n\">aa_threshold</span>\n\n<span class=\"n\">x</span> <span class=\"o\">=</span> <span class=\"n\">np</span><span class=\"o\">.</span><span class=\"n\">linspace</span><span class=\"p\">(</span><span class=\"o\">-</span><span class=\"mi\">1</span><span class=\"p\">,</span> <span class=\"mi\">1</span><span class=\"p\">,</span> <span class=\"mi\">1000</span><span class=\"p\">)</span>\n<span class=\"n\">y</span> <span class=\"o\">=</span> <span class=\"n\">circle2d_sdf</span><span class=\"p\">(</span><span class=\"n\">x</span><span class=\"p\">,</span> <span class=\"mf\">0.5</span><span class=\"p\">)</span>\n\n<span class=\"n\">plt</span><span class=\"o\">.</span><span class=\"n\">plot</span><span class=\"p\">(</span><span class=\"n\">x</span><span class=\"p\">,</span> <span class=\"n\">y</span><span class=\"p\">)</span>\n</pre></div>\n\n    </div>\n</div>\n</div>\n\n<div class=\"output_wrapper\">\n<div class=\"output\">\n\n\n<div class=\"output_area\">\n\n    <div class=\"prompt output_prompt\">Out[1]:</div>\n\n\n\n\n<div class=\"output_text output_subarea output_execute_result\">\n<pre>[&lt;matplotlib.lines.Line2D at 0x7f3797b91210&gt;]</pre>\n</div>\n\n</div>\n\n<div class=\"output_area\">\n\n    <div class=\"prompt\"></div>\n\n\n\n\n<div class=\"output_png output_subarea \">\n<img src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAiMAAAGdCAYAAADAAnMpAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/P9b71AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAzAklEQVR4nO3dfXRU5YHH8d+8ZCYJ5EVAA5EQ0VVBY10NVcAivkax2vasZ8HVBbTgMUsVgdoul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IBbWM+L7Cw/QcQDkg4jhw4d0u7du7V7925JfVN3d+/erbq6Okl9XSzz5s2Lnl9ZWamPP/5Yy5Yt0969e7V582Zt2rRJ991334mpARyv8EjzagthBECCrOdFYU7I5pIgHZLupnnnnXd05ZVXRr+2xnbMnz9fW7ZsUX19fTSYSNLEiRO1bds2LV26VI899piKi4v16KOPMq3XQ6yWEcIIgERZzwvr+YHMlnQYueKKK6IDUOPZsmXLgGMzZ87Url27kv1VyBDWw6S9q1ddPRGFguxCAGBohBFv4a8CTrq87KMPE1pHACSiub3vWZFPGPEEwghOuoDfp7zsvkY4wgiARNAy4i2EEaQF40YAJIMw4i2EEaSFNaOG6b0AEhGdTcNiZ55AGEFa0DICIBmttIx4CmEEaWE9UJrbu2wuCQA3aD7c96wgjHgDYQRpcbRlpMfmkgBwA8aMeAthBGmRTzcNgCRYzwqm9noDYQRpYS3pTBgBkIiWdlpGvIQwgrRgACuAREUiRm2dfV26zKbxBsII0oKdewEkqq2jR9auI7SMeANhBGkRnU1zmNk0AIZmPSdyQwFlBfgz5QVcZaQF3TQAEsVMGu8hjCAtCCMAEkUY8R7CCNKi4MggtI7uiDp7em0uDQAnI4x4D2EEaZEXDsrn6/uc1hEAQyGMeA9hBGnh9/uUn82MGgDHRxjxHsII0ubo/jSEE

Python dependencies

alabaster==0.7.12
antlr4-python3-runtime==4.10.1
anyio==3.6.2
appdirs==1.4.4
arandr==0.1.10
argcomplete==2.0.0
argon2-cffi==21.3.0
argon2-cffi-bindings==21.2.0
arrow==1.2.3
asttokens==2.2.1
attrs==22.2.0
Babel==2.10.3
backcall==0.2.0
Beaker==1.10.0
beautifulsoup4==4.11.2
bleach==6.0.0
blivet==3.5.0
blivet-gui==2.4.0
Brlapi==0.8.4
Brotli==1.0.9
cairocffi==1.3.0
CairoSVG==2.5.2
certifi==2021.10.8
cffi==1.15.1
chardet==5.1.0
charset-normalizer==2.1.0
click==8.1.3
colorlog==6.6.0
comm==0.1.2
construct==2.10.68
contourpy==1.0.7
cryptography==37.0.2
cssselect==1.1.0
cssselect2==0.6.0
cupshelpers==1.0
cycler==0.11.0
Cython==0.29.32
dasbus==1.6
dbus-next==0.2.3
dbus-python==1.3.2
debugpy==1.6.6
decorator==5.1.1
defusedxml==0.7.1
distro==1.7.0
dnspython==2.2.1
docutils==0.18.1
eduvpn-client==3.1.0
executing==1.2.0
fastjsonschema==2.16.3
fb-re2==1.0.7
fedora-third-party==0.10
file-magic==0.4.0
filelock==3.7.1
fonttools==4.37.2
fqdn==1.5.1
fros==1.1
fs==2.4.11
future==0.18.3
gmpy2==2.1.3
gpg==1.17.0
gssapi==1.7.3
humanize==3.13.1
i3ipc==2.2.1
icoextract==0.1.4
idna==3.4
ifaddr==0.1.7
imagesize==1.2.0
importlib-metadata==4.12.0
initial-setup==0.3.95
ipykernel==6.21.2
ipython==8.11.0
ipython-genutils==0.2.0
ipywidgets==8.0.4
isoduration==20.11.0
jaraco.classes==3.2.1
jedi==0.18.2
jeepney==0.8.0
Jinja2==3.1.2
jsonpointer==2.3
jsonschema==4.17.3
jupyter==1.0.0
jupyter-console==6.6.2
jupyter-events==0.6.3
jupyter_client==8.0.3
jupyter_core==5.2.0
jupyter_server==2.3.0
jupyter_server_terminals==0.4.4
jupyterlab-pygments==0.2.2
jupyterlab-widgets==3.0.5
keyring==23.11.0
kiwisolver==1.4.4
koji==1.32.0
langtable==0.0.61
legendary-gl==0.20.32
libcomps==0.1.18
lxml==4.9.1
Mako==1.1.4
mapbox-earcut==1.0.1
Markdown==3.4.1
MarkupSafe==2.1.2
matplotlib==3.6.3
matplotlib-inline==0.1.6
mercurial==6.2.3
meson==1.0.0
mistune==2.0.5
more-itertools==8.12.0
mpmath==1.2.1
msgpack==1.0.4
munkres==1.1.2
nbclassic==0.5.2
nbclient==0.7.2
nbconvert==7.2.9
nbformat==5.7.3
nest-asyncio==1.5.6
networkx==2.8.8
nftables==0.1
notebook==6.5.2
notebook_shim==0.2.2
numexpr==2.8.1
numpy==1.22.0
numpy-stl==2.16.3
oauthlib==3.2.1
olefile==0.46
packaging==23.0
pandocfilters==1.5.0
parso==0.8.3
Paste==3.5.0
patool==1.12
pefile==2023.2.7
pexpect==4.8.0
pickleshare==0.7.5
pid==2.2.3
Pillow==9.2.0
platformdirs==3.1.0
ply==3.11
productmd==1.35
progressbar2==3.53.2
prometheus-client==0.16.0
prompt-toolkit==3.0.38
psutil==5.9.4
ptyprocess==0.7.0
pure-eval==0.2.2
pwquality==1.4.5
pybeam==0.7
pycairo==1.21.0
pycollada==0.7.2
pycparser==2.21
pycrypto==2.6.1
pycups==2.0.1
pycurl==7.45.1
pydot==1.4.2
pydub==0.25.1
pyenchant==3.2.2
pygit2==1.7.1
pyglet==1.5.23
Pygments==2.14.0
PyGObject==3.42.2
pygpu==0.7.6
pygraphviz==1.10
PyJWT==2.4.0
pykickstart==3.41
PyNaCl==1.4.0
pyOpenSSL==21.0.0
pyparsing==3.0.9
pyparted==3.12.0
PyQt5==5.15.6
PyQt5-sip==12.11.0
pyrsistent==0.19.3
pyserial==3.5
PySide2==5.15.7
PySocks==1.7.1
PySoundFile==0.9.0.post1
pystray==0.17.3
python-augeas==1.1.0
python-dateutil==2.8.2
python-gettext==4.0
python-json-logger==2.0.7
python-manatools==0.0.4
python-meh==0.50
python-utils==3.1.0
python-xlib==0.31
pytz==2022.7.1
pyudev==0.23.2
pyxdg==0.27
PyYAML==6.0
pyzmq==25.0.0
qtconsole==5.4.0
QtPy==2.3.0
regex==2022.10.31
requests==2.28.1
requests-file==1.5.1
requests-ftp==0.3.1
requests-gssapi==1.2.3
requests-oauthlib==1.3.1
rfc3339-validator==0.1.4
rfc3986-validator==0.1.1
rpm==4.18.0
rpmautospec==0.3.5
rpmlint==2.4.0
Rtree==1.0.0
SciPy==1.8.1
scour==0.38.2
SecretStorage==3.3.3
selinux==3.5
Send2Trash==1.8.0
sepolicy==3.5
setools==4.4.0
setproctitle==1.2.3
setroubleshoot==3.3.32
Shapely==1.8.5.post1
shiboken2==5.15.7
simpleaudio==1.0.4
simpleline==1.9.0
six==1.16.0
sniffio==1.3.0
snowballstemmer==2.2.0
sos==4.4
soupsieve==2.4
Sphinx==5.0.2
sphinxcontrib-applehelp==1.0.2
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==2.0.0
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.5
stack-data==0.6.2
svg.path==4.1
sympy==1.11.1
systemd-python==235
Tempita==0.5.2
tenacity==8.0.1
terminado==0.17.1
Theano-PyMC==1.1.2
tinycss2==1.2.1
tomli_w==1.0.0
tornado==6.2
traitlets==5.9.0
trimesh==3.20.1
uri-template==1.2.0
urllib3==1.26.12
virt-firmware==1.8
wcwidth==0.2.6
webcolors==1.12
webencodings==0.5.1
websocket-client==1.5.1
widgetsnbextension==4.0.5
xcffib==0.11.1
xxhash==3.2.0
zeroconf==0.38.7
zipp==3.8.1
zstandard==0.19.0
github-actions[bot] commented 1 year ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.