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

Fix memory leak in VerticalMetricsTable #409

Merged
merged 1 commit into from
Aug 1, 2024

Conversation

Bykiev
Copy link
Contributor

@Bykiev Bykiev commented Jul 29, 2024

This PR fixes memory leak in VerticalMetricsTable

This PR fixes memory leak in VerticalMetricsTable
Copy link

codecov bot commented Jul 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86%. Comparing base (91405e3) to head (baca1eb).
Report is 5 commits behind head on main.

Additional details and impacted files
@@          Coverage Diff          @@
##            main    #409   +/-   ##
=====================================
  Coverage     86%     86%           
=====================================
  Files        238     238           
  Lines      15255   15257    +2     
  Branches    2108    2108           
=====================================
+ Hits       13234   13240    +6     
+ Misses      1550    1546    -4     
  Partials     471     471           
Flag Coverage Δ
unittests 86% <100%> (+<1%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -47,7 +47,10 @@ internal short GetTopSideBearing(int glyphIndex)
return null;
}

return Load(binaryReader, headTable.NumberOfVMetrics, profileTable.GlyphCount);
using (binaryReader)
Copy link
Member

Choose a reason for hiding this comment

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

Nice job finding this! Did you find it profiling or just by chance?

Copy link
Contributor Author

@Bykiev Bykiev Aug 1, 2024

Choose a reason for hiding this comment

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

I've used Roslyn analyzer, there are some other issues, but due to used patterns in Fonts/ImageSharp I still investigating if it can be fixed (there are some non-sealed classes with non-virtual Dispose and some classes has a local variables, where class is not an owner of it). For. ex., FontReader class has a variable stream, but it has no Dispose, but some other classes implements it

Copy link
Member

Choose a reason for hiding this comment

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

I'd be careful with that analyzer, I've seen many, many false positives.

FontReader doesn't own the input stream so shouldn't be responsible for its lifecycle. It's perfectly fine for the type to use a private variable to hold the reference.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it'll should be used carefully, because of such FPs

Copy link
Contributor Author

@Bykiev Bykiev Aug 1, 2024

Choose a reason for hiding this comment

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

I'll prepare some interesting cases and will add an appropriate discussion if needed, still need some time to research all warnings...

Copy link
Member

@JimBobSquarePants JimBobSquarePants left a comment

Choose a reason for hiding this comment

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

Thanks for this. Much appreciated!

@JimBobSquarePants JimBobSquarePants merged commit 165a348 into SixLabors:main Aug 1, 2024
9 checks passed
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