Steema Issues Database

Note: 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.



Bug 2048

Summary: TChart is not collcted by gc in xamrin.ios
Product: .NET TeeChart Reporter: Bill <bill2004158>
Component: iOSAssignee: 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:

Description Bill 2018-06-26 05:45:03 EDT
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
Comment 2 pep jorge 2018-07-18 10:03:25 EDT
Changes have been applied to the latest TeeChart sources, considered for the next maintenance release.