热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

跟踪分配/内存使用,并在XCode中执行代码?-Trackallocations/memoryusageandalsostepthroughcodeinXCode?

Myappisdownloadingbase64encodedcontent,inmostcasesPDFdocuments.Itistransferredviaweb

My app is downloading base64 encoded content, in most cases PDF documents. It is transferred via web service and wrapped up in SOAP. The documents can reach sizes of up to 100 MB.

我的应用程序正在下载base64编码的内容,大多数情况下是PDF文档。它通过web服务传输,并包在SOAP中。这些文档的大小可以达到100 MB。

To store these files locally, I need to extract them from the SOAP envelop, decode the base64 string and write to storage.

要在本地存储这些文件,我需要从SOAP信封中提取它们,解码base64字符串并将其写入存储。

Problem is, that a document of about 1 MB increases the temporary memory usage by 20-30 MB. When tracking allocations in Instruments, I can see those peaks. This isn't so much a problem. But a document of 60 MB increases memory by around 800 MB, and that's definitely too much for iOS devices.

问题是,一个大约1 MB的文档会增加20-30 MB的临时内存使用量。这不是什么大问题。但是一个60mb的文档会增加800 MB的内存,这对iOS设备来说显然是太多了。

I'm trying to change the app so that the peaks can be prevented or at least lowered. Alas, I don't exactly know which lines of code are responsible.

我正在尝试改变应用程序,以便可以避免或者至少降低峰值。唉,我不知道哪行代码是负责任的。

Is there a possibility to step through the code and also view current allocations or memory usage at the same time?

是否有可能遍历代码并同时查看当前分配或内存使用情况?

I know stepping through doesn't work when app is executed by Instruments. So, are there any other options?

我知道,当应用程序被工具执行时,跨过去是行不通的。那么,还有其他选择吗?

Here is how Instruments looks like: enter image description here

仪器是这样的:

Thanks in advance!

提前谢谢!

2 个解决方案

#1


4  

To track allocations in a certain period of time, what I normally do is mark the start and end points in the timeline using the inspection range buttons:

为了在一定时间内跟踪分配情况,我通常使用inspection range按钮在时间轴上标记开始和结束点:

Instruments Inspection Range Buttons

That filters the allocations list and just shows you allocations done in that period of time. I normally sort by the "# living" column in order to find out what types of objects were allocated during that period. With the extended detail panel open, I select which ever suspicious object and click on the arrow by the class name:

它过滤了分配列表,只显示了在这段时间内完成的分配。我通常按“# living”列排序,以查明在此期间分配了什么类型的对象。打开扩展的细节面板,我选择任何可疑的对象,然后按类名单击箭头:

Instruments Allocations

That displays the list of instances of that type of object. Selecting one, will show you, in the extended panel, the stack trace. That information can already hint you how these objects are being allocated.

显示该类型对象的实例的列表。选择一个,将在扩展面板中显示堆栈跟踪。这些信息已经可以提示您如何分配这些对象。

In addition, if you select a particular instance using the arrow by the class name again, you see that object's history in terms of memory events. Also, if you double click on a stack trace call it will show you the code where that memory event is happening:

此外,如果您再次使用箭头按类名选择一个特定的实例,您将看到该对象的历史记录。此外,如果双击堆栈跟踪调用,它将显示内存事件发生的代码:

Object Stack Trace

With this information you should be able to know what is going on. If the object you selected is not the culprit, you can continue inspecting the rest. In order to navigate back to the object list you can click on "Object Summary" in the navigation bar:

有了这些信息,你应该能知道发生了什么。如果您选择的对象不是罪魁祸首,那么您可以继续检查其余的对象。要返回到对象列表,可以单击导航栏中的“对象摘要”:

Allocation Instruments Navigation Bar

Good hunting.

好打猎。

#2


1  

check out this link that helps you understands heap allocations. It will help you track the allocations.Hope this helps. You can also use activity monitor which lets you track the memory consumed by an app at any particular time when using the app.

检查这个帮助您理解堆分配的链接。它将帮助您跟踪分配。希望这个有帮助。您还可以使用activity monitor来跟踪应用程序在使用该应用程序时在任何特定时间消耗的内存。

you can also check the code that is allocating memory , please find attached screen shot.enter image description here

您也可以检查正在分配内存的代码,请找到所附的屏幕截图。


推荐阅读
  • Java序列化对象传给PHP的方法及原理解析
    本文介绍了Java序列化对象传给PHP的方法及原理,包括Java对象传递的方式、序列化的方式、PHP中的序列化用法介绍、Java是否能反序列化PHP的数据、Java序列化的原理以及解决Java序列化中的问题。同时还解释了序列化的概念和作用,以及代码执行序列化所需要的权限。最后指出,序列化会将对象实例的所有字段都进行序列化,使得数据能够被表示为实例的序列化数据,但只有能够解释该格式的代码才能够确定数据的内容。 ... [详细]
  • SQL Server 2008 到底需要使用哪些端口?
    SQLServer2008到底需要使用哪些端口?-下面就来介绍下SQLServer2008中使用的端口有哪些:  首先,最常用最常见的就是1433端口。这个是数据库引擎的端口,如果 ... [详细]
  • NetBPM的安装还是比较简单的,有比较详细的文档。1.当然是先下载运行程序了,netbpm-0.8.3.1.zip,官方网站ÿ ... [详细]
  • CSS3选择器的使用方法详解,提高Web开发效率和精准度
    本文详细介绍了CSS3新增的选择器方法,包括属性选择器的使用。通过CSS3选择器,可以提高Web开发的效率和精准度,使得查找元素更加方便和快捷。同时,本文还对属性选择器的各种用法进行了详细解释,并给出了相应的代码示例。通过学习本文,读者可以更好地掌握CSS3选择器的使用方法,提升自己的Web开发能力。 ... [详细]
  • ZSI.generate.Wsdl2PythonError: unsupported local simpleType restriction ... [详细]
  • 本文介绍了机器学习手册中关于日期和时区操作的重要性以及其在实际应用中的作用。文章以一个故事为背景,描述了学童们面对老先生的教导时的反应,以及上官如在这个过程中的表现。同时,文章也提到了顾慎为对上官如的恨意以及他们之间的矛盾源于早年的结局。最后,文章强调了日期和时区操作在机器学习中的重要性,并指出了其在实际应用中的作用和意义。 ... [详细]
  • 从零基础到精通的前台学习路线
    随着互联网的发展,前台开发工程师成为市场上非常抢手的人才。本文介绍了从零基础到精通前台开发的学习路线,包括学习HTML、CSS、JavaScript等基础知识和常用工具的使用。通过循序渐进的学习,可以掌握前台开发的基本技能,并有能力找到一份月薪8000以上的工作。 ... [详细]
  • 本文分析了Wince程序内存和存储内存的分布及作用。Wince内存包括系统内存、对象存储和程序内存,其中系统内存占用了一部分SDRAM,而剩下的30M为程序内存和存储内存。对象存储是嵌入式wince操作系统中的一个新概念,常用于消费电子设备中。此外,文章还介绍了主电源和后备电池在操作系统中的作用。 ... [详细]
  • mui框架offcanvas侧滑超出部分隐藏无法滚动如何解决
    web前端|js教程off-canvas,部分,超出web前端-js教程mui框架中off-canvas侧滑的一个缺点就是无法出现滚动条,因为它主要用途是设置类似于qq界面的那种格 ... [详细]
  • 浙江大学2005–2006学年秋冬季学期《大学计算机基础》课程期末考试试卷开课学院:计算中心,考试形式:闭卷,允许带入场考试 ... [详细]
  • {moduleinfo:{card_count:[{count_phone:1,count:1}],search_count:[{count_phone:4 ... [详细]
  • 浅析Mysql数据回滚错误的解决方法_PHP教程:MYSQL的事务处理主要有两种方法。1、用begin,rollback,commit来实现begin开始一个事务rollback事 ... [详细]
  • python是一门简单灵动的语言。从今天开始我要每天都做笔记,每天都要写博客记录我所想,我所学到的。笔记提纲:1,pyt ... [详细]
  • SOA架构理解理解SOA架构,了解ESB概念,明白SOA与微服务的区别和联系,了解SOA与热门技术的结合与应用。1、面向服务的架构SOASOA(ServiceOrien ... [详细]
  • 1.WebServicea.定义:WebService是一种跨编程语言和跨操作系统平台的远程调用技术b.三大技术:XMLXSD,SOAP, ... [详细]
author-avatar
再见看淡_266
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有