-
-
Notifications
You must be signed in to change notification settings - Fork 73
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 IDisposable usage #411
Conversation
This PR fixes a memory leak in FontReader with Woff2 fonts. Because of this FontReader class now implements IDisposable interface. This PR also wraps disposable types with using statements to remove warnings.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #411 +/- ##
=====================================
Coverage 86% 86%
=====================================
Files 238 238
Lines 15257 15263 +6
Branches 2108 2109 +1
=====================================
+ Hits 13240 13247 +7
+ Misses 1546 1545 -1
Partials 471 471
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for looking into this!
The changes look good just with some minor updates required. Looking at this PR reminds me I need to do a thorough style cleanup of the codebase!
@@ -26,7 +26,7 @@ public Buffer(int length) | |||
this.buffer = ArrayPool<byte>.Shared.Rent(bufferSizeInBytes); | |||
this.length = length; | |||
|
|||
ByteMemoryManager<T> manager = new(this.buffer); | |||
using ByteMemoryManager<T> manager = new(this.buffer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dispose()
doesn't actually do anything for this type but given that is an implementation detail disposing is probably appropriate.
However, the manager should be held as a private field of the parent Buffer<T>
and disposed at the end of the parent lifecycle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, didn't get the idea about the purpose of private field. You can contribute to my repo if you wish.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many thanks for this!
Thank you for your hard work! I'll continue with disposable in |
This PR fixes a memory leak in
FontReader
class withWoff2
fonts. Because of thisFontReader
class now implementsIDisposable
interface.This PR also wraps disposable types with using statements to remove warnings.