Skip to content

Conversation

caarlos0
Copy link
Member

@caarlos0 caarlos0 commented Jan 28, 2025

easily reproducible, especially with something like

PAGER="gum pager" man ls

Problems here were:

  • reflow's truncate is not very efficient
  • useless calls to truncate
  • bad strings.Replace calls (not necessary, and wouldn't work if text has ansi sequences)

Fixes #823

PS: this is better handled in #791, but that one is a bigger change (and depends on a /bubbles change as well), so I think we can probably do this instead for now and push a patch until #791 is done and merged.


before:

CleanShot 2025-01-28 at 11 24 21@2x

fixed on regular usage, search still broken

image

full fix

image

easily reproducible, especially with something like

```sh
PAGER="gum pager" man ls
```

Problems here were:
- reflow's truncate is not very efficient
- useless calls to truncate
- bad strings.Replace calls (not necessary, and wouldn't work if text has ansi sequences)
@caarlos0 caarlos0 self-assigned this Jan 28, 2025
@caarlos0 caarlos0 requested a review from a team as a code owner January 28, 2025 14:23
@caarlos0 caarlos0 requested review from csandeep and removed request for a team January 28, 2025 14:23
@caarlos0
Copy link
Member Author

also worth noting: memory usage, before x after

CleanShot 2025-01-28 at 11 29 18@2x

CleanShot 2025-01-28 at 11 32 01@2x

PS: first screenshot is just opening gum pager, second is navigating, otherwise there's actually no allocations ;)

caarlos0 added a commit that referenced this pull request Jan 28, 2025
Used this in #827 and found it quite useful.

Should we ship this to help both we and our users to see mem/cpu usage etc?
@meowgorithm meowgorithm removed the request for review from csandeep January 28, 2025 14:34
@caarlos0 caarlos0 mentioned this pull request Jan 28, 2025
@caarlos0 caarlos0 merged commit d1fc051 into main Jan 28, 2025
14 checks passed
@caarlos0 caarlos0 deleted the fix-pager-memleak branch January 28, 2025 14:50
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.

memory leak in pager
3 participants