![]() | Steema Issues DatabaseNote: This database is for bugs and wishes only. For technical support help, if you are a customer please visit our online forums;otherwise you can use StackOverflow. Before using this bug-tracker we recommend a look at this document, Steema Bug Fixing Policy. |
| Summary: | TChart is not collcted by gc in xamrin.ios | ||
|---|---|---|---|
| Product: | .NET TeeChart | Reporter: | Bill <bill2004158> |
| Component: | iOS | Assignee: | Steema Issue Manager <issuemanager> |
| Status: | RESOLVED FIXED | ||
| Severity: | enhancement | CC: | pep, sandra |
| Priority: | --- | ||
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | Phone | ||
| OS: | iOS | ||
| Chart Series: | --- | Delphi / C++ Builder RAD IDE Version: | |
Changes have been applied to the latest TeeChart sources, considered for the next maintenance release. |
in class TChart, there is such code: protected void initVars() { ... NSNotificationCenter.DefaultCenter.AddObserver((NSString)"UIDeviceOrientationDidChangedNotification", delegate { this.chart.Invalidate(); }); ... that code has two problems: 1. "UIDeviceOrientationDidChangedNotification" should be "UIDeviceOrientationDidChangeNotification" 2. added observer, when init, however, haven't unregister it when dispose this object. thus DefaultCenter will always refer to the delegate method, which caused gc will not collect the Tchart object. I think it should be like this: private readonly NSObject notification; protected void initVars() { ... notification = NSNotificationCenter.DefaultCenter.AddObserver((NSString)"UIDeviceOrientationDidChangedNotification", delegate { this.chart.Invalidate(); }); ... } protected override void Dispose(bool disposing) { if (disposing) { notification.Dispose(); } base.Dispose(disposing); } ref: https://developer.apple.com/documentation/uikit/uideviceorientationdidchangenotification