Skip to content

matchfuzzy() leaks allocated lists#17980

Closed
zeertzjq wants to merge 1 commit intovim:masterfrom
zeertzjq:retmatchpos
Closed

matchfuzzy() leaks allocated lists#17980
zeertzjq wants to merge 1 commit intovim:masterfrom
zeertzjq:retmatchpos

Conversation

@zeertzjq
Copy link
Copy Markdown
Member

@zeertzjq zeertzjq commented Aug 13, 2025

Problem: matchfuzzy() leaks allocated lists (after 9.1.1627).
Solution: Restore the "retmatchpos" condition.

The memory leak cannot be caught by ASAN as the garbage collector still
tracks these lists, but it can be reproduced by the following script,
which increases Vim's memory usage to over 1 GiB without this fix:

for i in range(100000)
  call matchfuzzy([repeat('a', 300)], repeat('a', 257))
endfor

related: #17900

@zeertzjq
Copy link
Copy Markdown
Member Author

cc @girishji

@girishji
Copy link
Copy Markdown
Contributor

Thanks for fixing this. I believe it was leaking the lmatchpos list.

Problem:  matchfuzzy() leaks allocated lists (after 9.1.1627).
Solution: Restore the "retmatchpos" condition.

The memory leak cannot be caught by ASAN as the garbage collector still
tracks these lists, but it can be reproduced by the following script,
which increases Vim's memory usage to over 1 GiB without this fix:

```vim
for i in range(100000)
  call matchfuzzy([repeat('a', 300)], repeat('a', 257))
endfor
```

related: vim#17900
@zeertzjq
Copy link
Copy Markdown
Member Author

Closing in favor of #17984

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