获取iOS应用程序使用的OpenGL纹理内存的实际数量 [英] Get the actual amount of OpenGL texture memory an iOS app uses

查看:127
本文介绍了获取iOS应用程序使用的OpenGL纹理内存的实际数量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SO中有几个与此问题类似的问题,但是似乎没有一个问题可以解释一种确定的方法来获取设备上iOS应用程序使用的实际OpenGL纹理内存.

There are a couple of questions in SO similar to this one, but none of them seem to explain a definitive approach for getting the actual OpenGL texture memory used by an iOS app, on the device.

我知道如何手动计算将纹理上传到OpenGL后将使用多少内存.我想知道是否可以从设备获取确切的OpenGL使用的内存量.

I know how to manually calculate how much memory my textures will use when uploaded to OpenGL. I want to know if I can get the exact OpenGL used memory amount from the device.

我想避免查看Instruments上"Memory Monitor"小部件中的"Real Memory"和"Virtual Memory"列(我的理解是,这些汇总了纹理内存和应用程序的常规内存).我认为这类似于此处

I would like to avoid looking at the Real Memory and Virtual Memory columns in the Memory Monitor widget on Instruments (my understanding is that these aggregate texture memory and app's regular memory). I presume this is similar to the approach shown here or here.

我不介意使用任何外部工具还是以编程方式获取纹理内存.但是我只需要设备报告的真实OpenGL内存,而不是聚合的内存.

I don't mind whether the texture memory is obtained using any external tool or programmatically. But I want just the real OpenGL memory as reported by the device, not an aggregate.

还可以有人解释虚拟内存"一栏在iOS上的确切含义吗?我想我了解虚拟内存,但我想弄清楚虚拟内存"列是否也与iOS内存不足警告相关,或者只有实内存"列与之相关.

Also, can somebody explain what the 'Virtual Memory' column exactly means on iOS? I think I understand the concept of Virtual Memory, but I'm trying to figure out if the Virtual Memory column is also related to iOS low-memory warnings, or only the Real Memory column is.

推荐答案

我的回答不完美,但是...

My answer is imperfect, but...

在连接设备并打开项目的情况下,请确保已将实际设备(而不是模拟器)选择为执行目标.选择产品->个人资料.

With your device attached and with the project open, ensure you have the actual device selected as the execution target and not the simulator. Select Product -> Profile.

仪器将会出现.选择"OpenGL ES分析"模板.仪器应在两个仪器处于活动状态时打开-"OpenGL ES分析器"和"OpenGL ES驱动程序".

Instruments will come up. Pick the 'OpenGL ES Analysis' template. Instruments should open with two instruments active — 'OpenGL ES Analyzer' and 'OpenGL ES Driver'.

单击分析仪的"i",然后勾选上载纹理字节".您将获得一张上传的字节数图.

Click the 'i' for the analyser and tick 'Uploaded Texture Bytes'. You'll get a graph of the number of bytes uploaded.

就在Instruments的顶部面板和底部面板之间的分隔线之后,您应该在箭头形的框中看到文本"OpenGL ES Analyzer",可能指向"Expert"一词.单击专家",然后选择框架统计信息".您将获得一个表,其中的一列是"Uploaded Texture Bytes".

Just after the dividing line between the top and bottom panels in Instruments you should see the text 'OpenGL ES Analyzer' in an arrow-shaped box, probably pointing over to the word 'Expert'. Click on 'Expert' and select 'Frame Statistics'. You'll get a table in which one of the columns is 'Uploaded Texture Bytes'.

这是令人讨厌的部分:列出每个帧中上载的字节数.到目前为止,我还没有找到一种方法来获取当前居民费用或以其他方式对该列进行任何自动计算.但是它仅显示仪器"检查范围内的内容(由窗口工具栏上的时钟按钮设置),因此您可以将检查限制在特定时间段内,然后自己累加结果.

Here's the annoying part: that lists the number of bytes uploaded in every frame. As of yet I've not found a way to get the current resident cost or otherwise to do any automatic calculation with that column. But it display only what's in the Instruments inspection range — set by the clock buttons on the window's toolbar — so you can restrict your inspection to a certain time period and then add up the results yourself.

我无法100%确定虚拟内存"专栏的确切含义(想必您指的是内存监视器"工具?),但iOS具有功能齐全的虚拟内存系统.它唯一不会做的就是将数据分页到磁盘.但是,您可以使用内存映射文件,并且操作系统可能会使用通常的虚拟方法来分配内存.什么malloc和合作. create是可保留一个地址空间块的票证.除非或直到使用它,否则实际内存不会放入该地址空间.由于它实际上是免费的,因此可能为您分配的虚拟内存比实际使用的要多得多.毫无疑问,所有基础对象都针对正在使用的内存管理系统进行了优化.

I can't be 100% definitive on the exact implications of the 'Virtual Memory' column (you're referring to the Memory Monitor tool, presumably?) but iOS has a fully functioning virtual memory system. The only thing it won't do is page data out to disk. You can however memory map a file and it's likely that the OS uses the usual virtual approach to allocating memory. What malloc and co. create is a ticket that reserves a block of address space. Actual memory isn't put into that address space unless or until you use it. Since it's essentially free, you may be allocated quite a lot more virtual memory than you're actually using; no doubt all of the foundation objects are optimised for the memory management system at play.

这篇关于获取iOS应用程序使用的OpenGL纹理内存的实际数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆