Skip to content

Disable nanobind leak tracking by removing NB_STATIC flag#60

Draft
ctgk with Copilot wants to merge 7 commits into
developfrom
copilot/fix-nanobind-reference-leaks
Draft

Disable nanobind leak tracking by removing NB_STATIC flag#60
ctgk with Copilot wants to merge 7 commits into
developfrom
copilot/fix-nanobind-reference-leaks

Conversation

Copilot AI commented Feb 13, 2026

Copy link
Copy Markdown

Running pytest raised nanobind reference leak warnings for module-level constructs (enums, types, functions). These are documented false positives - the objects intentionally persist for the module's lifetime.

Changes

cpp/python/CMakeLists.txt: Removed NB_STATIC from all nanobind_add_module() calls:

  • _vshogi
  • _minishogi
  • _judkins_shogi
  • _shogi

Technical rationale

NB_STATIC links nanobind as a static library and enables leak tracking - useful for development, but inappropriate for production code with module-level constructs. Without it, nanobind links as a shared library with leak tracking disabled at compile time.

This eliminates warnings without code-level suppressions (nb::set_leak_warnings(false)), while reducing binary size through shared library usage.

Original prompt

running pytest raises nanobind reference leak warnings.

https://nanobind.readthedocs.io/en/latest/refleaks.html

Please detect the source of the leaks and fix them.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits February 13, 2026 10:04
… warnings

Co-authored-by: ctgk <25563881+ctgk@users.noreply.github.com>
Co-authored-by: ctgk <25563881+ctgk@users.noreply.github.com>
Co-authored-by: ctgk <25563881+ctgk@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix nanobind reference leak warnings in pytest Suppress nanobind module-level reference leak warnings Feb 13, 2026
Copilot AI requested a review from ctgk February 13, 2026 10:10
@ctgk

ctgk commented Feb 13, 2026

Copy link
Copy Markdown
Owner

i dont like simply supressing the warnings.
nb::set_leak_warnings(false)

Copilot AI and others added 2 commits February 13, 2026 11:13
Co-authored-by: ctgk <25563881+ctgk@users.noreply.github.com>
Co-authored-by: ctgk <25563881+ctgk@users.noreply.github.com>
Copilot AI changed the title Suppress nanobind module-level reference leak warnings Disable nanobind leak tracking by removing NB_STATIC flag Feb 13, 2026
@ctgk ctgk force-pushed the develop branch 2 times, most recently from a484cb5 to 07005fa Compare May 18, 2026 12:06
@ctgk ctgk force-pushed the develop branch 5 times, most recently from 3ea2a14 to 401cbc0 Compare July 12, 2026 06:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants