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

Enumerate once on clone. Fix #1073 #1074

Merged
merged 1 commit into from
Jan 9, 2020
Merged

Enumerate once on clone. Fix #1073 #1074

merged 1 commit into from
Jan 9, 2020

Conversation

JimBobSquarePants
Copy link
Member

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following matches the existing coding patterns and practice as demonstrated in the repository. These follow strict Stylecop rules 👮.
  • I have provided test coverage for my change (where applicable)

Description

We were allowing enumerating our source ImageFrame<TPixel> collection more than once on clone causing memory leaks so I've switched the code to explicitly enumerate once and pass an array to the new image constructor.

Fixes #1073

@@ -122,7 +122,7 @@ public abstract class ImageFrameCollection : IEnumerable<ImageFrame>
public IEnumerator<ImageFrame> GetEnumerator() => this.NonGenericGetEnumerator();

/// <inheritdoc/>
IEnumerator IEnumerable.GetEnumerator() => this.NonGenericGetEnumerator();
IEnumerator IEnumerable.GetEnumerator() => this.GetEnumerator();
Copy link
Member Author

Choose a reason for hiding this comment

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

Best to call the method above to ensure no diversion is possible in future refactoring.

@codecov
Copy link

codecov bot commented Jan 9, 2020

Codecov Report

Merging #1074 into master will decrease coverage by 0.12%.
The diff coverage is 91.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1074      +/-   ##
==========================================
- Coverage   89.95%   89.83%   -0.13%     
==========================================
  Files        1200     1200              
  Lines       53010    53013       +3     
  Branches     3844     3847       +3     
==========================================
- Hits        47687    47623      -64     
- Misses       4555     4562       +7     
- Partials      768      828      +60
Impacted Files Coverage Δ
src/ImageSharp/ImageFrameCollection.cs 90% <0%> (ø) ⬆️
src/ImageSharp/Image{TPixel}.cs 90% <100%> (+0.34%) ⬆️
...essing/Processors/CloningImageProcessor{TPixel}.cs 90.38% <100%> (+0.18%) ⬆️
...c/ImageSharp/Formats/Tga/TgaImageTypeExtensions.cs 60% <0%> (-20%) ⬇️
...xelFormats/PixelOperations{TPixel}.PixelBenders.cs 89.9% <0%> (-10.1%) ⬇️
...olorSpaces/Conversion/ColorSpaceConverter.Adapt.cs 60% <0%> (-8.58%) ⬇️
...Processing/Processors/Transforms/TransformUtils.cs 87.64% <0%> (-6.75%) ⬇️
src/ImageSharp/Primitives/ValueSize.cs 78.94% <0%> (-5.27%) ⬇️
src/ImageSharp/Common/Helpers/ImageMaths.cs 82.5% <0%> (-5%) ⬇️
....Tests/TestUtilities/Tests/TestEnvironmentTests.cs 63.63% <0%> (-4.55%) ⬇️
... and 26 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dadc274...5b7052c. Read the comment docs.

@JimBobSquarePants
Copy link
Member Author

I'm just gonna go ahead an merge this one. It's a trivial and obvious fix.

@JimBobSquarePants JimBobSquarePants merged commit 06bf7ac into master Jan 9, 2020
@JimBobSquarePants JimBobSquarePants deleted the js/fix-1073 branch January 9, 2020 03:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing ToList in CloningImageProcessor?
1 participant