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 - TChart is not collcted by gc in xamrin.ios
Summary: TChart is not collcted by gc in xamrin.ios
Status: RESOLVED FIXED
Alias: None
Product: .NET TeeChart
Classification: Unclassified
Component: iOS (show other bugs)
Version: unspecified
Hardware: Phone iOS
: --- enhancement
Target Milestone: ---
Assignee: Steema Issue Manager
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-06-26 05:45 EDT by Bill
Modified: 2018-07-18 10:03 EDT (History)
2 users (show)

See Also:
Chart Series: ---
Delphi / C++ Builder RAD IDE Version:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.