3

我有这样的问题。我正在开发一个 iPad 应用程序,它实际上使用了很多图像和核心动画内容。我没有泄漏,但我已经放弃了内存问题。我有稳定的记忆增长。我禁用了实际上使用大量内存的动画,但内存增长仍然存在问题。对于动画,我使用http://markpospesel.wordpress.com/2012/05/07/mpfoldtransition/。我已经将 UIImage 类中此类加载方法的实现替换为“imageNamed:”等。但它仍然没有帮助。

如果有人有任何想法,请提供帮助。

谢谢大家。

仪器截图

+ (UIImage *)imageNamed:(NSString *)name {
    NSString *pathExtension = [name pathExtension];
    name = [name stringByDeletingPathExtension];
    if ([pathExtension isEqualToString:@""]) {
        pathExtension = @"png";
    }

    NSString *sufix = [BMKAppUtilites isRetina] ?  @"@2x" : @"";
    name = [name stringByAppendingString:sufix];
    name = [name stringByAppendingPathExtension:pathExtension];

    name = [[NSBundle mainBundle] pathForResource:[name stringByDeletingPathExtension] ofType:[name pathExtension]];
    return [[self alloc] initWithData:[NSData dataWithContentsOfFile:name options:NSDataReadingUncached error:NULL] scale:[BMKAppUtilites scaleFactor]];
}
4

1 回答 1

1

编辑:我刚刚注意到这个问题已经超过 6 年了。

——</p>

它看起来很像某些东西仍然对您的图像有很强的参考。我想说根据您向我们展示的数据,您最好的选择是从 Xcode 运行并在内存图中暂停以查看具有强引用的内容。不要忘记在您的方案中打开 malloc 堆栈跟踪,以便跟踪分配内存的位置。祝你好运。

如果您从未使用过 Xcode 内存图,这可能会有所帮助:https ://developer.apple.com/documentation/xcode/improving_your_app_s_performance/reducing_your_app_s_memory_use/gathering_information_about_memory_use

于 2020-08-14T03:02:50.750 回答