Nanobind leaked instances warnings

I get nanobind leaked instances warnings after running any case. I’ve been watching my RAM but I do not see anything unusual. Is this something I can ignore? These are the warnings that I get when I run demo_poisson.py:

Install 'pyvista' with pip: 'python3 -m pip install pyvista'
nanobind: leaked 10 instances!
nanobind: leaked 1 keep_alive records!
nanobind: leaked 6 types!
 - leaked type "dolfinx.cpp.mesh.Mesh_float64"
 - leaked type "dolfinx.cpp.fem.FiniteElement_float64"
 - leaked type "dolfinx.cpp.fem.FunctionSpace_float64"
 - leaked type "dolfinx.cpp.fem.DofMap"
 - leaked type "dolfinx.cpp.la.Vector_float64"
 - leaked type "dolfinx.cpp.la.Norm"
nanobind: leaked 43 functions!
 - leaked function "signature"
 - leaked function "map"
 - leaked function ""
 - leaked function ""
 - leaked function "scatter_forward"
 - leaked function ""
 - leaked function "__init__"
 - leaked function "contains"
 - leaked function "pre_apply_inverse_transpose_dof_transformation"
 - leaked function ""
 - leaked function ""
 - ... skipped remainder
nanobind: this is likely caused by a reference counting issue in the binding code.

I’m working with the latest version of dolfinx (commit 0a6570392ac8adae23ff98f44c0c2a48f7be4c5f) compiled in a container built from ghcr.io/fenics/test-env:current-mpich. To reproduce the issue, I connect to a new temporary container like this:

xhost si:localuser:root
docker run --rm --network=host --shm-size=512m -ti -v $(realpath ~/bin/FEniCSx/):/root/shared -w /root/shared --entrypoint /bin/bash ghcr.io/fenics/test-env:current-mpich

where you have to change ~/bin/FEniCSx/ with the directory where you have dolfinx, basix, etc. Then I install dolfinx and run demo_poisson.py :

apt update
apt install -y libboost-program-options-dev
apt-get install -y python3-pip
python3 -m pip install --upgrade pip setuptools
wget https://gist.githubusercontent.com/jorgensd/e1984f6055b0f91197be6e406f0c901f/raw/e8b3b4307f53cc8054b719d5a148ef76fc2cfcf0/bash_commands.md
sed -i "1,3d" bash_commands.md
sed -i "60,61d" bash_commands.md
cat bash_commands.md >> .bashrc
rm bash_commands.md
source .bashrc
basix
ufl_ffcx
rebuild dolfinx clean cpp python
cd $HOME/shared/dolfinx/python/demo/
python3 demo_poisson.py

It is something you can ignore. Nanobind picks up memory leaks relating to Python itself,

2 Likes