Skip to content

Conversation

@Anthony-Eid
Copy link

This function incorrectly assumed that
CTFontCollectionCreateMatchingFontDescriptors doesn't follow the Create rule which is false.

From Apple's docs

A retained reference to an array of normalized font descriptors
matching the collection definition.

I also confirmed using instruments that this was causing a memory leak in Zed.

This function incorrectly assumed that
`CTFontCollectionCreateMatchingFontDescriptors` doesn't follow the
*Create* rule which is false.

From Apple's docs

> A retained reference to an array of normalized font descriptors
  matching the collection definition.

https://leopard-adc.pepas.com/documentation/Carbon/Reference/CTFontCollectionRef/Reference/reference.html#//apple_ref/c/func/CTFontCollectionCreateMatchingFontDescriptors

I also confirmed using instruments that this was causing a memory leak
in Zed.
Copy link
Contributor

@madsmtm madsmtm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Introduced in 4914947 (2012).

Maybe it was a bug in the macOS version at the time?

@Anthony-Eid
Copy link
Author

Anthony-Eid commented Dec 17, 2025

Introduced in 4914947 (2012).

Maybe it was a bug in the macOS version at the time?

That would make sense. To be honest, I didn't check the file history. I just figured "bugs happen" and I should make a PR to fix it. The leak isn't the biggest deal for Zed since we cache the results, but I would still really appreciate it if this got merged.

Anthony-Eid added a commit to zed-industries/zed that referenced this pull request Dec 17, 2025
The below memory leaks were caused by failing to release reference
counted resources. I confirmed using instruments that my changes stopped
the leaks from occurring.

- System prompts 
- Screen capturing 
- loading font families

There were also two memory leaks I found from some of our dependencies
that I made PRs to fix
- RustAudio/coreaudio-rs#147
- servo/core-foundation-rs#746

Release Notes:

- N/A
HactarCE pushed a commit to zed-industries/zed that referenced this pull request Dec 17, 2025
The below memory leaks were caused by failing to release reference
counted resources. I confirmed using instruments that my changes stopped
the leaks from occurring.

- System prompts 
- Screen capturing 
- loading font families

There were also two memory leaks I found from some of our dependencies
that I made PRs to fix
- RustAudio/coreaudio-rs#147
- servo/core-foundation-rs#746

Release Notes:

- N/A
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