ChartsOrg / ChartsOrg/Charts

Memory leak when used in macOS app with SwiftUI App life cycle.

Open
#4,555 1 comment 0 reactions 0 assignees View on GitHub
missing info
Dominant language
Swift
Stars
28k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

## What did you do?

I used NSViewRepresentable to embed a Line Chart in a SwiftUI view setting the chart up with the code from the sample Mac app. The app used the new SwiftUI App lifecycle.

## What did you expect to happen?

I expected the chart to draw without leaking memory.

## What happened instead?

There were hundreds of memory leaks.
There were no leaks when running the same code in a SwiftUI app with the AppKit AppDelegate life cycle.
There were no leaks when drawing the same chart in an AppKit app instead of using SwiftUI.

I really think this is a SwiftUI bug rather than a Charts bug, but I am documenting it here as it would have saved me a lot of time to know this.

## Charts Environment

**Charts version/Branch/Commit Number:** v3.6.0/master/6654640
**Xcode version:** 12.3 (12C33)
**Swift version:** 5.3.2
**Platform(s) running Charts:** macOS
**macOS version running Xcode:** 11.1

Contributor guide

Open the contributing guide

Research direction

No repository file or test is named. Start by reproducing the chart through NSViewRepresentable in a SwiftUI App lifecycle, then compare it with the AppKit AppDelegate lifecycle and a native AppKit app. Done means determining whether the leaks are in Charts or SwiftUI and documenting a confirmed reproduction.

Written by the indexing model from the issue text.

Assessment

Tech stack
macos, swift
Domain
desktop
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.