- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
最近我将我的应用程序的最大内存峰值从 100 MB 减少到 45 MB,我很好奇使用 android:largeHeap="true"除了有可能将其他应用程序推出内存?如果大小没有增长到足以证明推出其他应用程序是合理的,这不是一个很好的故障保护,例如,如果您的应用程序只打算在一次崩溃可能是灾难性的 session 上使用四天?还是我正在寻找其他一些骗局?
最佳答案
作为this training guide指出,
"Using the extra memory will increasingly be to the detriment of the overall user experience because garbage collection will take longer and system performance may be slower when task switching or performing other common operations."
我认为这是一个非常有效的问题,让我对此添加一些额外的解释。
1) 更长的垃圾收集时间:
很难衡量更大的堆需要多少额外时间。因为很多事情都会影响垃圾收集时间。使用哪个 Android 运行时(Dalvik 或 ART)会影响垃圾收集时间(您可以在 here 查看更多信息)。垃圾回收在 different Android version 上的执行方式也不同。 .但可以肯定的是,更大的堆会使垃圾收集时间更长。因为垃圾收集器基本上必须遍历整个 Activity 对象集。如果你好奇,你可以从Memory management for Android Apps了解更多关于这个话题。 2011 年 Google I/O session 。正如 session 幻灯片中所述,垃圾收集暂停时间约为 5 毫秒。你可能认为几毫秒没什么大不了的,但每一毫秒都很重要。 Android 设备必须每 16 毫秒更新一次屏幕,较长的 GC 时间可能会使您的帧处理时间超过 16 毫秒的障碍,这会导致明显的卡顿。
2) 任务切换较慢:
如解释here ,
the system may kill processes in the LRU cache beginning with the process least recently used, but also giving some consideration toward which processes are most memory intensive.
因此,如果您使用更大的堆,您的进程在后台时更有可能被杀死,这意味着当用户想要从其他应用切换到您的应用时可能需要更长的时间。当您的进程处于前台时,后台进程也更有可能被踢出,因为您的应用程序需要更大的内存。这意味着从您的应用程序切换到其他应用程序也需要更长的时间。这些显然对用户不利。
关于android - 使用android :largeHeap ="true"?有什么缺点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26189619/
我目前正在尝试编写一个函数,它将一个新元素添加到列表顶部,并将列表的其余部分推回...任何人都可以帮助我吗?当我尝试编译和运行我的程序时,它不起作用。它无限循环。有什么帮助吗? #include #
我有时在程序中使用表情符号来突出显示代码的某些部分(在开源库中)。每个脚本我很少使用超过 5-6 个,而且我发现它们在文本编辑器中的颜色确实很突出。 通常,它们是 transient 标记,并且会在与
假设我有一个像这样的(有点人为的组件) const ExampleComponent = (props) => { const renderList = () => {
谁能告诉我在 WPF 中使用命令与事件的优点是什么?命令或事件是否会遇到内存泄漏?什么是最快的方法。它们的缺点是什么? 最佳答案 与事件处理程序相比,命令具有两个主要优点: 命令未链接到调用者,所以相
我应该使用什么?或者是否有特殊场合我应该使用其中一种而不是另一种? 最佳答案 对于更高维度,K 图不一定失败。问题在于,对五个以上的变量进行可视化非常困难。 4 变量 K 图是二维的并且易于可视化。第
在使用kubernetes部署我的应用程序和数据库容器时,我试图了解以下体系结构的优缺点。 背景知识:该应用程序位于Nginx代理后面。所有请求都从代理流向Web服务器。 Web服务器是唯一有权访问(
有多种脚本环境可用于 .NET 应用程序(例如 this post)。 我的问题是,使用它们各自的优缺点是什么? 示例包括(但不限于) PowerShell IronPython 路亚 JavaScr
以下是我在访问资源文件时看到的 3 个选项。由于可能存在异常(exception)情况,选项 1 可能是最不推荐的,因此问题实际上与选项 2 或选项 3 相关,即哪个是首选或推荐的实现。 选项 1 -
Effective Java - Item-2 states, a JavaBean may be in an inconsistent state partway through its const
我不希望每次旋转设备时都重新创建我的 Activity,所以我将 android:configChanges="keyboardHidden|orientation"标签放在我的 list 文件中。
关闭。这个问题是opinion-based 。目前不接受答案。 想要改进这个问题吗?更新问题,以便 editing this post 可以用事实和引文来回答它。 . 已关闭 8 年前。 Improv
我有一个工作分配方案,其中每个单元都进行一些簿记和管理,并将任务传递给订单链中的下一个单元,例如;假设有 3 个类:老板、经理、 worker class Boss { void do_asy
创建一个包含字段 A、B、C 的唯一键然后创建另一个包含字段 C、B、A 的唯一键是否有缺点,因此 MySQL 将在仅使用 A 和仅使用 A 进行搜索的情况下利用索引C? 最佳答案 您不想创建额外的复
我对 JavaScript 中的原型(prototype)设计和构造函数很陌生。我看到有人这样声明构造函数: var Person = (function(){ function Person
假设我有一个 json 数据对象,我想将其解析为我自己的对象。我遇到过两种方法。第一种是像这样使用初始化程序: class DataModelOne { let firstProperty: S
在c++中我们可以调用一个类的方法而不用实例化它。比如; MyClass mc; mc.method(); 在不实例化类的情况下使用类方法的优点和缺点是什么?我们什么时候应该使用这种类型? 最佳答案
我需要更好地了解 web 开发,尤其是 CSS 的工作原理。我从事 Web 开发已有大约 2 年了,我认为现在是时候了解如何优化我网站的性能了。我想问的事情不多。 首先: 每当我的页面上有标签内容时,
代码如下: .thumbnail { float:left; width:110px; height:90px; margin:5px; }
上下文:数据库规范化,我正在创建一个表:UserInvolvement。User 可以通过多种方式(基于角色和其他方式)参与另一个实体:Foo。在当前情况下,每种类型的参与都作为单独的列添加到 Foo
按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
我是一名优秀的程序员,十分优秀!