You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.4 KiB

/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#import <UIKit/UIKit.h>
@interface MemoryLeaks
@property(strong) UIView* backgroundCoveringView;
@property(strong) UIView* attachmentContainerView;
@end
@implementation MemoryLeaks
- (void)cg_path_create_with_rect_no_leak_good {
UIView* attachmentContainerView = [UIView alloc];
CGPathRef shadowPath =
CGPathCreateWithRect(attachmentContainerView.bounds, NULL);
CGPathRelease(shadowPath);
}
- (void)cg_path_create_with_rect_leak_bad {
CGPathRef shadowPath =
CGPathCreateWithRect(self.backgroundCoveringView.bounds, NULL);
self.backgroundCoveringView.layer.shadowPath = shadowPath;
}
+ (void)cg_path_create_mutable_leak_bad:(CGRect)rect {
0.20f * CGRectGetHeight(rect);
CGPathCreateMutable();
}
+ (void)cg_path_create_mutable_no_leak_good:(CGRect)rect {
CGFloat lineThickness = 0.20f * CGRectGetHeight(rect);
// One rectangle
CGMutablePathRef path = CGPathCreateMutable();
if (!path)
return;
CFRelease(path);
}
+ (void)cg_bitmap_context_create_image_no_leak_good {
CGImageRef newImage = CGBitmapContextCreateImage(nil);
CGImageRelease(newImage);
}
+ (void)cg_bitmap_context_create_image1_no_leak_good {
CGImageRef newImage = CGBitmapContextCreateImage(nil);
CFAutorelease(newImage);
}
@end