Commit 01b22b4
Summary:
When running the Python test suite, SWIG emits a warning:
```
swig/python detected a memory leak of type 'std::unordered_multimap< faiss::Index::idx_t,faiss::Index::idx_t > *', no destructor found.
```
The root cause is that `faiss::IndexIVFFlatDedup::instances` is a `std::unordered_multimap<idx_t, idx_t>` member, and SWIG has no built-in destructor registration for that STL type. When SWIG wraps the field, it generates a raw pointer wrapper with no cleanup, causing the leak warning whenever an `IndexIVFFlatDedup` object is garbage-collected on the Python side.
The fix adds `%ignore faiss::IndexIVFFlatDedup::instances` in `faiss/python/swigfaiss.swig` before the `%include <faiss/IndexIVFFlat.h>` directive. This prevents SWIG from generating the untyped wrapper for the internal dedup map (which was never exposed in the Python type stubs anyway) and eliminates the memory leak warning.
Fixes #1667
Pull Request resolved: #5145
Reviewed By: trang-nm-nguyen
Differential Revision: D102668055
Pulled By: mnorris11
fbshipit-source-id: e865d9463aecc4d9c37447602b33e1cf71011007
1 parent a31dad3 commit 01b22b4
2 files changed
Lines changed: 4 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
569 | 569 | | |
570 | 570 | | |
571 | 571 | | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
572 | 575 | | |
573 | 576 | | |
574 | 577 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| |||
0 commit comments