python: pcbnew.FootprintLoad leaks memory

Description

This is problem with python bindings. Using pcbnew.FootprintLoad() leaks memory. Seems to be related with usage of GetPluginForPath (pcbnew/python/swig/footprint.i) because using PCB_IO_KICAD_SEXPR directly seems to be solving this.

Steps to reproduce

import sys
sys.path.insert(0, '/home/aws/git/kicad/kicad/build/kicad-install/usr/local/lib/python3.13/site-packages')
import pcbnew

lib_uri = "/usr/share/kicad/footprints/Diode_SMD.pretty"
fp_name = "D_SOD-123F"

for i in range(0, 100):
    if False: # ok variant
        sexpr = pcbnew.PCB_IO_KICAD_SEXPR()
        print(f"{sexpr=}")
        fp = sexpr.FootprintLoad(lib_uri, fp_name)
        print(f"{fp=}")
    else: # leaky variant:
        fp = pcbnew.FootprintLoad(lib_uri, fp_name)
        print(f"{fp=}")

call with

LD_LIBRARY_PATH=/home/aws/git/kicad/kicad/build/kicad-install/usr/local/lib python reproduce.py

(I tested against local build to check if this happens no master - it does. Same for release 9.0.6)

ok variant leaky variant
ok leaky

(graphs generated with https://github.com/bloomberg/memray)

KiCad Version

Application: KiCad PCB Editor x86_64 on x86_64

Version: 9.0.6, release build

Libraries: wxWidgets 3.2.9 FreeType 2.14.1 HarfBuzz 12.2.0 FontConfig 2.17.1 libcurl/8.17.0 OpenSSL/3.6.0 zlib/1.3.1 brotli/1.1.0 zstd/1.5.7 libidn2/2.3.8 libpsl/0.21.5 libssh2/1.11.1 nghttp2/1.68.0 nghttp3/1.13.1 mit-krb5/1.21.3

Platform: Arch Linux, 64 bit, Little endian, wxGTK, X11, , tty OpenGL: NVIDIA Corporation, NVIDIA GeForce RTX 5090/PCIe/SSE2, 4.6.0 NVIDIA 580.105.08

Build Info: Date: Dec 9 2025 16:07:51 wxWidgets: 3.2.9 (wchar_t,wx containers) GTK+ 3.24 Boost: 1.89.0 OCC: 7.9.3 Curl: 8.17.0 ngspice: 45 Compiler: GCC 15.2.1 with C++ ABI 1020

Build settings: KICAD_USE_EGL=ON KICAD_IPC_API=ON

Locale: Lang: en_US Enc: UTF-8 Num: 1,234.5 Encoded кΩ丈: D0BACEA9E4B888 (sys), D0BACEA9E4B888 (utf8)