Memory leak when using singleCharWidget for ios

I have modified the singleCharSample project to simulated an issue that I have with my project. The modification is the following:
If I click on the smiley button, the existing singleCharWidget is removed from the superview and set to nil and then a new one is created.
Unfortunately, the memory of the new allocation is never released and my application crash after 10 initialisations after getting memory warning.
How should I do to release properly the memory?

Here the code :

- (IBAction)smileyButtonTap:(id)sender {

[_singleCharWidget removeFromSuperview];
_singleCharWidget = nil;

// Widget registration
_singleCharWidget = [[SCWSingleCharWidget alloc] initWithFrame:CGRectMake(100, 300, 80 , 150)];
NSData *certificate = [NSData dataWithBytes:myCertificate.bytes length:myCertificate.length];
_isRegistered = [_singleCharWidget registerCertificate:certificate];

if (!_isRegistered)
UIAlertController *alertController = [UIAlertController
alertControllerWithTitle:@"Invalid certificate"
message:@"Please use a valid certificate."
UIAlertAction *okAction = [UIAlertAction
handler:^(UIAlertAction * _Nonnull action) {
[alertController addAction:okAction];
[self presentViewController:alertController animated:YES completion:nil];

NSBundle *mainBundle = [NSBundle mainBundle];
NSString *bundlePath = [mainBundle pathForResource:@"resources" ofType:@"bundle"];
bundlePath = [bundlePath stringByAppendingPathComponent:@"conf"];

[self.singleCharWidget setInkColor:[UIColor colorWithRed:0.200f green:0.710f blue:0.898f alpha:1.0f]];
[self.singleCharWidget setInkWidth:7.0f];
[self.singleCharWidget setWordCandidateListSize:5];
[self.singleCharWidget setBackgroundColor:[UIColor yellowColor]];
[_singleCharWidget addSearchDir:bundlePath];

[self.singleCharWidget configureWithBundle:@"en_US" andConfig:@"si_text"];
[NSThread sleepForTimeInterval:0.1];

self.singleCharWidget.delegate = self;
self.candidatesLayoutHeight = CANDIDATE_BUTTON_HEIGHT;

[self.view addSubview:_singleCharWidget];
[self.textView setEditable:NO];

Dear Sarah,

thank you for contacting us.

Currently, we found out this issue in the Single Char Widget on iOS. It will normally be solved in the coming release of the ATK, that should be released within few weeks.

Best regards,


Dear Sarah,

just a quick update to notify issue is normally solved in the latest ATK available for download on this developer portal.

Best regards,


Login or Signup to post a comment