Skip to content
This repository has been archived by the owner on Feb 3, 2021. It is now read-only.

Memory issue #52

Closed
lionhylra opened this issue Oct 21, 2015 · 9 comments
Closed

Memory issue #52

lionhylra opened this issue Oct 21, 2015 · 9 comments

Comments

@lionhylra
Copy link

I created a view(shimmerView) and added a FBShimmerView onto it. Then I make my app do this loop:
Show the shimmerView, go to other views, go to shimmerView, go to other views...

Everything was normal except that something increased in the memory.
So I opened Instrument to see what happened. And it showed that instances of FBShimmeringLayer and FBShimmeringMaskLayer increased by one every tine a FBShimmerView is displayed. That means when a FBShimmerView is deallocated, the FBShimmeringLayer is persisted in the memory.
See the screenshot below:
screenshot 2015-10-21 17 17 44

@grp
Copy link
Contributor

grp commented Oct 21, 2015

Do you have the latest commit in place? There was a retain cycle that got fixed: 32ded5b

@lionhylra
Copy link
Author

Thanks. I used the package on cocoaPods.

@grp
Copy link
Contributor

grp commented Oct 21, 2015

I'll put out an update for that soon, but for now you should be able to point Cocoapods to that commit. Thanks for filing!

@grp grp closed this as completed Oct 21, 2015
@lionhylra
Copy link
Author

I just use the latest commit and test it in the Instrument. The FBShimmeringLayer and FBShimmeringMaskLayer are still retained. Could you have a check?

@grp
Copy link
Contributor

grp commented Oct 22, 2015

When you say the instances increase when it is 'displayed', what do you mean by that? Are you asking it to start shimmering? Are you simply adding it to the view hierarchy? Creating a new FBShimmeringView?

I would try limiting the operations you perform on the shimmering view, then go into the one operation that seems to cause the issue and find where it's allocating a new object.

@grp
Copy link
Contributor

grp commented Oct 22, 2015

I pushed another commit that might help. Let me know if that fixes it.

@lionhylra
Copy link
Author

Please see my code below:

@interface LoginViewController()
@property (nonatomic, weak) IBOutlet FBShimmeringView * shimmerView;
@property (nonatomic, weak) IBOutlet UITextField * emailTextField;
@property (nonatomic, weak) IBOutlet UITextField * passwordTextField;
@property (nonatomic, weak) IBOutlet UIButton * loginButton;
@end
@implementation JLPLoginViewController
- (void)viewDidLoad {
    [super viewDidLoad];
    [self showLogo];
}
-(void)showLogo{
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:self.shimmerView.bounds];
    imageView.image = [UIImage imageNamed:@"logo"];
    imageView.contentMode = UIViewContentModeScaleAspectFit;
    self.shimmerView.contentView = imageView;

    // Start shimmering.
    self.shimmerView.shimmering = YES;
}
@end

What I did is:

  1. I instantiate the LoginViewController from storyboard in '- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions', and assign it to the rootViewController of main window
  2. When the login button is tapped, I instantiate another view controller and assign to the rootViewController of main window. At this moment, the LoginViewController should have been deallocated.
  3. When the logout button is tapped, instantiate a LoginViewController and assign it to the rootViewController of main window again. At this moment, the FBShimmeringLayer of previous LoginViewController is not deallocated and a new instance of FBShimmeringLayer is created for the new LoginViewController.

@lionhylra
Copy link
Author

After trying the last commit, I find the issue is still there.
screenshot 2015-10-22 11 38 17
screenshot 2015-10-22 11 38 36

@grp
Copy link
Contributor

grp commented Oct 22, 2015

Unfortunately, you'll have to debug this yourself. It may be due to the specifics of how you're using Shimmer.

@grp grp reopened this Oct 22, 2015
@grp grp closed this as completed Oct 22, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@grp @lionhylra and others