Skip to content

[BUG] MatchedItem should be Weak<dyn SkimItem> to prevent cycles #988

@kimono-koans

Description

@kimono-koans

Describe the bug
Chained invocations of skim retain lots of memory. I believe there is cycle within skim which prevents Arc<dyn SkimItem> from being dropped.

pub struct MatchedItem {
    /// The underlying skim item
    pub item: Arc<dyn SkimItem>,
    /// The rank/score of this match
    pub rank: Rank,
    /// Range of characters that matched the pattern
    pub matched_range: Option<Box<MatchRange>>,
}

To Reproduce
Steps to reproduce the behavior:

  1. Invoke skim as a library.
  2. Allow skim to build up a substantial number of SkimItems (hundreds of thousands).
  3. Search the SkimItems a few times.
  4. Exit skim invocation, but keep a main process running. skim retains hundreds megabytes of memory (hundreds of megabytes, even a gigabyte of non-purgeable memory).

Expected behavior
For skim to deallocate as much memory as possible.

Environment (please complete the following information):

  • OS (uname -a): MacOS 26.3 and Ubuntu 24.04.4
  • skim version (sk --version): 3.2.0
  • Shell and version: zsh 5.9-6ubuntu2
  • Variables (env | grep '^SKIM'): None

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions