iOS端 Hayya项目Leaks检测
发现首页有大量内存泄漏
查看项目代码后,发现很多block里使用了self,造成循环应用。
通过修改循环引用
发现还是存在严重的内存泄漏,经过排查定位到OMTAppConfigHttpRequest.m中AFNetworking的错误写法。
‘- (void)post:(NSString *)urlString
parameters:(id)parameters
complete:(void (^)(id responseObjec))completed
failure:(void (^)(NSError *error)) failure
{
GCSocialNetworkClient *networkClient = [[GCSocialNetworkClient alloc] initWithBaseURL:[NSURL URLWithString:URL_GAMCO_SOCIAL_DOMAIN]];
networkClient.responseSerializer = [MBResponseSerializer serializer];
networkClient.requestSerializer = [MBRequestSerializer serializer];
[networkClient.requestSerializer setValue:@"" forHTTPHeaderField:@"User-Agent1"];
[self networkClient:networkClient postUrl:urlString parameters:parameters complete:^(id responseObjec) {
completed(responseObjec);
} failure:^(NSError *error) {
failure(error);
}];
}’
修改后
‘- (void)post:(NSString *)urlString
parameters:(id)parameters
complete:(void (^)(id responseObjec))completed
failure:(void (^)(NSError *error)) failure
{
[self networkClient:[HYAFNetWorkManager sharedManager] postUrl:urlString parameters:parameters complete:^(id responseObjec) {
completed(responseObjec);
} failure:^(NSError *error) {
failure(error);
}];
}’
最终首页内存检测如下
内存泄漏情况明显改善。