Skip to content

Add a self-test for find_memleak to reduce false positives from probe warmup. - #995

Merged
junkmd merged 4 commits into
enthought:mainfrom
junkmd:find_memleak_tool_self_testing
Nov 15, 2026
Merged

junkmd merged 4 commits into
enthought:mainfrom
junkmd:find_memleak_tool_self_testing

Conversation

@junkmd

@junkmd junkmd commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator

Summary

Add a self-test for the memory-leak diagnostic helper (find_memleak / wss).

The test checks a practical way to avoid one class of false positives: one-time costs of the first wss() call in a process landing between the baseline and final readings inside find_memleak.

This is a small preparatory step before work on issue #971.

Motivation

find_memleak takes a baseline with one wss() call and a final reading with another. The first wss() call in a process can incur one-time costs (for example, pages being faulted in the first time certain code paths run). Those costs can appear as growth even when the function under test does not leak.

Calling wss() once beforehand pays that cost early, so the later measurement is less likely to report a false leak.

This only warms up the probe itself. Warmup of the target function is already handled inside find_memleak.

This is a practical workaround. It does not fix the deeper limitation of Working Set–based measurement (see #971): a stable Working Set does not prove the absence of a leak.

Changes

  • Add Test_find_memleak that exercises a known leak-free function (CoGetMalloc alloc/free).
  • Call wss() once before find_memleak so probe warmup does not pollute the measurement.
  • Document the rationale and the remaining limitations in comments.

Value

@junkmd junkmd added this to the 1.5.1 milestone Nov 15, 2026
@junkmd junkmd added tests enhance or fix tests ci labels Nov 15, 2026
@codecov-commenter

codecov-commenter commented Nov 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.74%. Comparing base (1e87ca6) to head (2d4e441).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #995      +/-   ##
==========================================
+ Coverage   91.73%   91.74%   +0.01%     
==========================================
  Files         149      150       +1     
  Lines       15357    15380      +23     
==========================================
+ Hits        14088    14111      +23     
  Misses       1269     1269              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@junkmd
junkmd merged commit 17242b9 into enthought:main Nov 15, 2026
197 of 202 checks passed
@junkmd
junkmd deleted the find_memleak_tool_self_testing branch November 15, 2026 23:29
junkmd added a commit to junkmd/comtypes that referenced this pull request Nov 15, 2026
…be warmup. (enthought#995)

* feat: Add type hints to `find_memleak`.

* test: Add an initial unstable test.

* test: Enhance `test_find_memleak` with `wss()` warmup to stabilize memory measurements.

* test: Refactor comments in `test_find_memleak` for clarity on `wss()` usage.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci tests enhance or fix tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants