Reputation: 10520
I'm having an issue with a memory leak. In Instruments, I'm getting a memory leak on this line:
VDLPlaybackViewController *videoController = [[VDLPlaybackViewController alloc] initWithNibName:@"VDLPlaybackView" bundle:nil];
I'm not sure what could be the issue on this. Here is the header file for VDLPlaybackViewController.h
:
@protocol VDLPlaybackViewControllerDelegate <NSObject>
@required
-(void)playerShouldClose;
@end
@interface VDLPlaybackViewController : UIViewController <UIDocumentInteractionControllerDelegate>
@property (nonatomic, strong) id<VDLPlaybackViewControllerDelegate> delegate;
// content file stuff.
@property (nonatomic, strong) File *file;
@property (nonatomic, strong) NSNumber *contentID;
@property (nonatomic, strong) NSURL *fileURL;
@property (nonatomic, strong) NSString *pageTitle;
// layout stuff
@property (strong, nonatomic) IBOutlet NSLayoutConstraint *topTimeViewHeight;
@property (strong, nonatomic) IBOutlet NSLayoutConstraint *bottomControlViewHeight;
@property (nonatomic, strong) IBOutlet UIView *movieView;
@property (nonatomic, strong) IBOutlet UIView *navBarView;
@property (nonatomic, strong) IBOutlet UISlider *positionSlider;
@property (nonatomic, strong) IBOutlet UIButton *timeDisplay;
@property (nonatomic, strong) IBOutlet UIButton *playPauseButton;
@property (nonatomic, strong) IBOutlet UIButton *subtitleSwitcherButton;
@property (nonatomic, strong) IBOutlet UIButton *audioSwitcherButton;
@property (nonatomic, strong) IBOutlet UIButton *screenSizeSwitcherButton;
//@property (nonatomic, strong) IBOutlet UINavigationBar *toolbar;
@property (nonatomic, strong) IBOutlet UIView *controllerPanel;
@property (nonatomic, strong) IBOutlet UISlider *volumeSlider;
@property (nonatomic, strong) IBOutlet MPVolumeView *volumeView;
@property (nonatomic, strong) IBOutlet MPVolumeView *airplayView;
@property (nonatomic, assign) CGRect shareButtonFrame;
@property (nonatomic, strong) MultiFileShareButtonController *shareButtonController;
@property (nonatomic, strong) FavoriteFileButtonView *favoriteButtonController;
@property (nonatomic, strong) UIDocumentInteractionController *interactionController;
@property (nonatomic, assign) BOOL isDestroying;
- (void)setMediaURL:(NSURL*)theURL;
- (IBAction)closePlayback:(id)sender;
- (IBAction)positionSliderDrag:(id)sender;
- (IBAction)positionSliderAction:(id)sender;
- (IBAction)toggleTimeDisplay:(id)sender;
- (IBAction)playandPause:(id)sender;
//- (IBAction)switchAudioTrack:(id)sender;
//- (IBAction)switchSubtitleTrack:(id)sender;
- (IBAction)switchVideoDimensions:(id)sender;
@end
Does anyone know what causes this?
Upvotes: 0
Views: 83
Reputation: 2908
The instrumentation tool tells you that there is a leak on the following line:
VDLPlaybackViewController *videoController = [[VDLPlaybackViewController alloc] initWithNibName:@"VDLPlaybackView" bundle:nil];
It does not mean, that it's just this line which is causing the leak, the tool is telling you that a reference of this variable exists as a leak.
You should look for instances where a strong reference to VDLPlaybackViewController *videoController
was passed.. may be as delegates or in completion blocks.
The interface which you have in the question has a little problem. It should be weak instead of strong
@property (nonatomic, weak) id<VDLPlaybackViewControllerDelegate> delegate;
Find more instances like this, where you've passed around VDLPlaybackViewController
as a strong reference delegate and you would be able to resolve the problem.
To understand more on why the leak is actually happening. Go through https://cocoacasts.com/what-are-strong-reference-cycles
Upvotes: 1