Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running notcurses-demo consumes a lot of memory. #885

Closed
nsxz1234 opened this issue Nov 15, 2023 · 5 comments · Fixed by #924
Closed

Running notcurses-demo consumes a lot of memory. #885

nsxz1234 opened this issue Nov 15, 2023 · 5 comments · Fixed by #924
Labels
needs-confirmation A reproduction has been reported, but the bug hasn't been confirmed or reproduced by a maintainer.

Comments

@nsxz1234
Copy link
Collaborator

swappy-20231115_225401

@mitchellh
Copy link
Contributor

This may be just merged into #254, but I’ll take a Quick Look to see if there is anything obvious/egregious standing out i.e. if this is a leak or if this is just a situation where we aren’t resizing back down from a large scrollback or something.

Importantly, this appears to be on Linux, so things like Kitty image protocol are immediately out of the question (since it’s disabled currently on Linux due to the render work not being done). That narrows it down a bit because Ghostty really doesn’t do that much allocation beyond the screen state.

@mitchellh mitchellh added bug needs-confirmation A reproduction has been reported, but the bug hasn't been confirmed or reproduced by a maintainer. and removed apprt/gtk labels Nov 15, 2023
@mitchellh
Copy link
Contributor

I ran this through macOS leak detector (via Instruments.app) and there is no purposeful leak it can find. One thing I did notice is that memory balloons when we're going through glyphs and I think that's because we never shrink the codepoint cache. So that's an easy win.

Another I noticed is that memory really skyrocketed during the "yields" demo but for that one I have no idea why yet.

@mitchellh
Copy link
Contributor

One thing I did notice is that memory balloons when we're going through glyphs and I think that's because we never shrink the codepoint cache.

I no longer believe this to be true. I removed the cache entirely and don't see a noticeable memory difference. I also did some math and realized that even with 1,000,000 cached code points and glyphs it uses less than 30MB of RAM so this isn't it.

@mitchellh
Copy link
Contributor

Actually, this doesn't reproduce at all on macOS. The screenshot below is macOS. The bottom instance is the one where I launched and ran notcurses-demo and the memory usage is very low. It does appear however that on Linux the memory usage is MUCH higher, suspicious!

CleanShot 2023-11-20 at 20 38 46@2x

mitchellh added a commit that referenced this issue Nov 21, 2023
Fixes #885

Interestingly, this isn't that big of a leak for whatever reason on
macOS. But on Linux with fontconfig this is a MASSIVE memory leak.
@mitchellh
Copy link
Contributor

Okay! I found a massive memory leak with fontconfig and fallback fonts on Linux. I don't think in a realistic environment this would cause many problems but nocturnes creates a pretty large set of font discovery queries so it's really apparent. After this, my memory usage is stable after a certain point for demo runs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-confirmation A reproduction has been reported, but the bug hasn't been confirmed or reproduced by a maintainer.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants