繁体   English   中英

我怎样才能解决 SwiftUI 中的“由于 memory 错误而被攻击”的问题?

[英]How could I solve the "teminted due to memory error" issue in SwiftUI?

我是新的 IOS 应用程序开发人员,我的应用程序是为我的公司开发的,但由于 memory 问题而崩溃。 在调查 Xcode 仪器时,我发现当“All Heap and Anonymous VM”达到某些位时,它会崩溃。 然后,我详细查看了 Xcode 仪器,发现当“All Heap and Anonymous VM”达到2.53 Gib total bytes“All Anonymous VM”达到2.28 Gib total bytes“VM:ImageIO_PNG_Data”达到1.80时应用程序终止Gib 总字节数 我还发现,当我单击图像按钮时(我使用 AsyncImage 对图像按钮进行编码,图像按钮中的图像来自 API。我将在下面列出我的 AsymcImage 代码。),匿名 VM 的持久性和总字节数呈指数级增长。 除此之外,其他接口对匿名虚拟机和其他 memory 数字的增加没有贡献。 因此,我猜问题出在这些图像按钮上。 我正在尝试找出调试和优化的解决方案。

这是跟踪 memory 的警告消息和我的图片:

警告信息

Xcode 仪表

这是界面:

接口:图像按钮

这是我的 AsyncImage 代码:

ForEach(userVM.user_data,id:\.self){ data in
    ForEach(userVM.getAllBusinessSegFor(index: data.client, com: data.businessSegments)) { segment in
        
        NavigationLink(destination:
                        CompanyList(
                            //title:item.name,
                            segment:segment,
                            companyParse: data.companies,
                            company:userVM
                        )){
                            AsyncImage(url: URL(string: "https://xxxxxxxxx.com\(segment.img)" )){
                                phase in
                                switch phase{
                                case .empty:
                                    ProgressView()
                                case .success(let returedImage):
                                    returedImage
                                        .resizable()
                                        .scaledToFill()
                                        .frame(width:314.38,height: 100)
                                    
                                    
                                case .failure:
                                    Image(systemName: "questionmark")
                                        .font(.headline)
                                default:
                                    Image(systemName: "questionmark")
                                        .font(.headline)
                                }
                            }
                        }
    }
}

我不太确定所有这些参数的含义,并且想知道解决此问题的方法是什么。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM