Skip to content

Memory Leak in PPOProjectCardViewModel due retain cycle, leaking view model #2732

@amanjeetsingh150

Description

@amanjeetsingh150

Steps to reproduce

I've been writing a tool XCTestLeaks, which runs the unit test in the target host app (Kickstarter in this case), at the tear down it runs the macOS leaks tool to detect retain cycles. I've found a retain cycle in PPOProjectCardViewModel. Report:

 29 (1.81K) ROOT CYCLE: <PPOProjectCardViewModel 0x170ce3f30> [320]
         8 (384 bytes) __strong rewardToggleTappedSubject --> ROOT CYCLE: <Combine.PassthroughSubject<Swift.Bool, Swift.Never> 0x600009a1e140> [64]
            6 (304 bytes) __strong downstreams.single --> ROOT CYCLE: <Combine.PassthroughSubject<Swift.Bool, Swift.Never>.Conduit<Combine.Publishers.Debounce<Combine.PassthroughSubject<Swift.Bool, Swift.Never>, __C.OS_dispatch_queue>.(Inner in $1be99a228)<Combine.Subscribers.Sink<Swift.Bool, Swift.Never>>> 0x600009a1f040> [64]
               3 (208 bytes) __strong downstream --> ROOT CYCLE: <Combine.Publishers.Debounce<Combine.PassthroughSubject<Swift.Bool, Swift.Never>, __C.OS_dispatch_queue>.(Inner in $1be99a228)<Combine.Subscribers.Sink<Swift.Bool, Swift.Never>> 0x6000036f2c00> [176]
                  1 (16 bytes) downstreamLock --> <Combine.Publishers.Debounce<Combine.PassthroughSubject<Swift.Bool, Swift.Never>, __C.OS_dispatch_queue>.(Inner in $1be99a228)<Combine.Subscribers.Sink<Swift.Bool, Swift.Never>>.downstreamLock (malloc) 0x6000101c3230> [16]
                  1 (16 bytes) lock --> <Combine.Publishers.Debounce<Combine.PassthroughSubject<Swift.Bool, Swift.Never>, __C.OS_dispatch_queue>.(Inner in $1be99a228)<Combine.Subscribers.Sink<Swift.Bool, Swift.Never>>.lock (malloc) 0x6000101c0c50> [16]
               1 (16 bytes) downstreamLock --> <Combine.PassthroughSubject<Swift.Bool, Swift.Never>.Conduit<Combine.Publishers.Debounce<Combine.PassthroughSubject<Swift.Bool, Swift.Never>, __C.OS_dispatch_queue>.(Inner in $1be99a228)<Combine.Subscribers.Sink<Swift.Bool, Swift.Never>>>.downstreamLock (malloc) 0x6000101c1af0> [16]
               1 (16 bytes) lock --> <Combine.PassthroughSubject<Swift.Bool, Swift.Never>.Conduit<Combine.Publishers.Debounce<Combine.PassthroughSubject<Swift.Bool, Swift.Never>, __C.OS_dispatch_queue>.(Inner in $1be99a228)<Combine.Subscribers.Sink<Swift.Bool, Swift.Never>>>.lock (malloc) 0x6000101c3d90> [16]
            1 (16 bytes) lock --> <Combine.PassthroughSubject<Swift.Bool, Swift.Never>.lock (malloc) 0x6000101c2c40> [16]
         5 (304 bytes) __strong cancellables._variant --> ROOT CYCLE: <Swift._SetStorage<Combine.AnyCancellable> 0x6000121da7b0> [80]

This is from the test here: testFinalizeYourPledge in PPOProjectCardTests.

Expected behavior

No Leaks

Environment

macOS 26.0.1, iOS 18.6, iPAD mini (A17 Pro)

Detailed Report

  • report.html: This is the main representative HTML output of all the artifacts
  • There is also raw xcodebuild output if you want to have look

leak_artifacts.zip

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions