Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

makoni
Copy link
Contributor

@makoni makoni commented Jul 31, 2025

These changes are now available in 4.5.1

I've noticed memory usage growth in my project that is described in #238

After adding some tests and running leaks, I found that currently there are retain cycles. That PR fixes them.

That's what leaks printed (a lot of similar messages):

  4 (352 bytes) ROOT CYCLE: <EncoderImpl 0x1572270d0> [80]
     3 (272 bytes) storage --> ROOT CYCLE: <Leaf.LeafEncoder.(KeyedContainerImpl in _30C79F4310B915184892E56903FC555A)<CodingKeys in Foo #1 in closure #1 (Vapor.Application) async throws -> () in LeafTests.LeafMemoryGrowthTests.testRepeatedRenderMemoryGrowth() async throws -> ()> 0x157227120> [48]
        __strong encoder --> CYCLE BACK TO <EncoderImpl 0x1572270d0> [80]
        2 (224 bytes) __strong data._variant --> <Swift._DictionaryStorage<Swift.String, Leaf.(LeafEncodingResolvable in _30C79F4310B915184892E56903FC555A)> 0x157227170> [192]  item count: 1
           1 (32 bytes) <Closure context 0x157227150> [32]

  2 (128 bytes) ROOT CYCLE: <EncoderImpl 0x156710ad0> [80]
     1 (48 bytes) storage --> ROOT CYCLE: <Leaf.LeafEncoder.(KeyedContainerImpl in _30C79F4310B915184892E56903FC555A)<CodingKeys in Foo #1 in closure #1 (Vapor.Application) async throws -> () in LeafTests.LeafMemoryGrowthTests.testRepeatedRenderMemoryGrowth() async throws -> ()> 0x156710b20> [48]
        __strong encoder --> CYCLE BACK TO <EncoderImpl 0x156710ad0> [80]

@makoni makoni requested review from 0xTim and gwynne as code owners July 31, 2025 07:19
…Impl and UnkeyedContainerImpl to prevent retain cycles"

This reverts commit 9a79408.
@codecov
Copy link

codecov bot commented Jul 31, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.33%. Comparing base (e7c3157) to head (bcfae49).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #239      +/-   ##
==========================================
+ Coverage   68.44%   76.33%   +7.89%     
==========================================
  Files           5        5              
  Lines         263      262       -1     
==========================================
+ Hits          180      200      +20     
+ Misses         83       62      -21     
Files with missing lines Coverage Δ
Sources/Leaf/LeafEncoder.swift 63.69% <ø> (+13.02%) ⬆️

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@gwynne gwynne 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 finding this!!

@gwynne gwynne added the semver-patch Internal changes only label Jul 31, 2025
@gwynne gwynne merged commit b70a610 into vapor:main Jul 31, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

semver-patch Internal changes only

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants