gpt4 book ai didi

objective-c - AFNetworking 崩溃,正在下载 200MB 以上的大文件

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:50:51 26 4
gpt4 key购买 nike

我下载 250MB 以下的文件没有问题,但当我尝试下载 250MB 以上的 zip 时,应用程序突然崩溃,没有任何错误。有时会通过,有时不会。泄漏确认没有膨胀或内存丧失。

我现在还注意到,只有当我使用 xcode 进行调试时才会发生崩溃。当我运行应用程序并在我没有调试的情况下下载较大的文件时,没有任何问题

在下载较大的文件时,我是否需要以不同的方式处理 AFNetworking 类?

这是我的代码

NSURL* url=[BFAppGlobals getServerURL:[M.Properties objectForKey:@"zip_path" ]];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setTimeoutInterval:3600];


AFHTTPRequestOperation *operation = [[[AFHTTPRequestOperation alloc] initWithRequest:request] autorelease];

NSString* writePath=[BFAppGlobals getContentResourcePathForFile:strFile];

[delegate onStartDownload:M];
operation.outputStream = [NSOutputStream outputStreamToFileAtPath:writePath append:YES];

[operation setDownloadProgressBlock:^(NSInteger bytesRead, NSInteger totalBytesRead, NSInteger totalBytesExpectedToRead) {

int b=totalBytesRead ;
int total=totalBytesExpectedToRead;
float perc=(float)b/(float)total;
M.progress=perc;
[((NSObject*)delegate) performSelectorOnMainThread:@selector(onDataReceviedFromRequest:) withObject:M waitUntilDone:YES];

}];

[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {

NSDictionary* params=[NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:writePath,writeDirectory, M, nil] forKeys:[NSArray arrayWithObjects:@"Path",@"Dir",@"Model", nil]];
[self performSelectorInBackground:@selector(unzipDownloaded:) withObject:params];


}
failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"fail! %@", [error localizedDescription]);
[delegate onErrorDownload:M WithError:[error localizedDescription]];
ActiveModel=nil;
}];

[operation start];



**************************** UPDATE ADDED CRASH LOG ***************************************

Thread 0 Crashed:
0 libobjc.A.dylib 0x37d24fbc objc_msgSend + 16
1 Foundation 0x35502508 __57-[NSNotificationCenter addObserver:selector:name:object:]_block_invoke_0 + 12
2 CoreFoundation 0x381aa570 ___CFXNotificationPost_block_invoke_0 + 64
3 CoreFoundation 0x381360c8 _CFXNotificationPost + 1400
4 Foundation 0x354763f4 -[NSNotificationCenter postNotificationName:object:userInfo:] + 60
5 Foundation 0x35477c24 -[NSNotificationCenter postNotificationName:object:] + 24
6 BFiPad 0x0006d2fc 0x1000 + 443132
7 CoreFoundation 0x3813d224 -[NSObject performSelector:withObject:] + 36
8 Foundation 0x35517750 __NSThreadPerformPerform + 344
9 CoreFoundation 0x381b2afc __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 8
10 CoreFoundation 0x381b22c8 __CFRunLoopDoSources0 + 208
11 CoreFoundation 0x381b106e __CFRunLoopRun + 646
12 CoreFoundation 0x381344d6 CFRunLoopRunSpecific + 294
13 CoreFoundation 0x3813439e CFRunLoopRunInMode + 98
14 GraphicsServices 0x37f0bfc6 GSEventRunModal + 150
15 UIKit 0x31cb473c UIApplicationMain + 1084
16 BFiPad 0x00003f72 0x1000 + 12146
17 BFiPad 0x00003f30 0x1000 + 12080

最佳答案

这似乎只发生在 Debug模式下。用完 Debug模式或发布更多解决此问题

关于objective-c - AFNetworking 崩溃,正在下载 200MB 以上的大文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10393524/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com