交换分区/文件如何影响系统? -- ram 领域 android 相关 的问题

How will a swap partition/file affect the system?


简体版||繁體版
20
vote

问题

中文

有朋友告诉我,他们的Android手机都非常小(小于100MB)进行定期的应用程序可用内存,因为操作系统和一些非killable服务占据了大部分内存。例如,一个带512MB的手机只显示90MB可用内存,因此只有2-3个应用程序可以同时运行。

我想知道创建交换分区/文件是否有帮助,但我在网络上看到了混合意见,我不确定该怎么办。以下是我的问题:

(1)是否会有许多非经常使用的内存页面来交换,尤其是在OS和那些不可删除的服务中?

(2)如何交换小的内存页面损伤闪存寿命?闪存(或SD卡是否?)自动磨损佩戴?

(3)在运行多个应用程序时会交换真正有助于性能吗?我假设(1)的答案是肯定的,它将。

(4)将写入闪光灯过于慢,因此在交换发生时损坏响应性?

(5)是Android将交换机制从Linux内核保留,因此只要有交换分区/文件,它就会在没有额外配置的情况下进行交换?

谢谢阅读。

英文原文

Some friends told me that their Android phones have very little (<100MB) available memory for regular apps, because the OS and some un-killable services take most of the RAM. For example, one phone with 512MB only shows 90MB available memory, so only 2-3 apps can run at the same time.

I'm wondering if creating a swap partition/file will help, but I saw mixed opinions all over the web and I'm not sure what to do. Here are my questions:

(1) Will there be many not-oftenly-used memory pages to swap out, especially in OS and those un-killable services?

(2) How will swapping out small memory pages hurt flash memory life span? Does the flash (or SD card?) do wear-leveling automatically?

(3) Will swapping really help performance when running multiple apps? I assume if the answer to (1) is yes, it will.

(4) Will writing to flash be too slow and thus hurt responsiveness when swapping happens?

(5) Is it true that Android keeps the swapping mechanism from the Linux kernel, so as long as there is a swapping partition/file, it will do swapping without extra configuration?

Thanks for reading.

  

回答列表

8
 
vote
vote
最佳答案
 

我不认为随着Android的交换会有很大的好处,因为Android应用程序生命周期是一种更先进的交换形式。

(1)有很多 不复用的内存页面交换 出来,特别是在操作系统和那些中 不可用的服务?

即使在Desktop Linux中,您也无法交换OS内核,并且Android在需要更多RAM时已经杀死了服务。如果您的设备供应商仍然存在,您必须在所有时间内运行无用的服务,然后root您的设备。

(2)如何交换小记忆 页面伤害了闪存救生方? 闪存(或SD卡吗?)做 自动磨损?

即使SD卡确实磨损,交换也会伤害很多。

(3)将交换真正的帮助 运行多个时性能 应用?我假设如果答案到(1)是 是的,它会。

不是在Android的上下文中。与传统的操作系统不同,它将在您要求的情况下继续在进程中挖掘过程中,Android将迫使旧的,未使用的流程并回收他们的内存;当您在任务交换机时,此杀戮快速迅速。

(4)写入闪光太慢 因此伤害响应性 交换发生?

可能,可能不是。将需要基准。

(5)是真实的,Android保留了 从Linux交换机制 内核,只要有一个 交换分区/文件,它会这样做 没有额外配置的交换?

我不知道Android是否会保持交换机制,但即使它(或者您编译自己的内核),您仍然需要一些配置。它通常只有 fstab 文件,它指向交换文件并做 swapon -a

事实上我有原因,为什么交换可能实际上可能会伤害性能:它可以防止应用程序生命周期,Android的内存管理方案,正常工作。
 

I don't think there will be much benefit with swapping for Android, as the Android Application Life Cycle is a much more advanced form of swapping.

(1) Will there be many not-oftenly-used memory pages to swap out, especially in OS and those un-killable services?

You can't swap the OS kernel even in Desktop Linux and Android already kills services when it needs more RAM. If your device vendor persists that you have to have useless services running all the time, then root your device.

(2) How will swapping out small memory pages hurt flash memory life span? Does the flash (or SD card?) do wear-leveling automatically?

Even if the SD-card does wear-leveling, swapping will hurt quite a lot.

(3) Will swapping really help performance when running multiple apps? I assume if the answer to (1) is yes, it will.

Not in the context of Android. Unlike traditional OS that will keep trying to chug in processes as you requested it, Android will Force Kill older, unused processes and reclaims their memory; this killing is fast as applications will already save their state when you task switch.

(4) Will writing to flash be too slow and thus hurt responsiveness when swapping happens?

Probably, probably not. Will need benchmarks for that.

(5) Is it true that Android keeps the swapping mechanism from the Linux kernel, so as long as there is a swapping partition/file, it will do swapping without extra configuration?

I don't know whether Android keeps the swapping mechanism, but even if it does (or if you compile your own kernel), you will still need some configurations. It's usually just having an fstab file that points to the swap file and doing swapon -a.

In fact I have reasons why swapping may actually hurt performance: it prevents Application Life Cycle, Android's memory management scheme, to work correctly.

 
 
         
         
5
 
vote

肯定有一个好处交换,尽管互联网上的其他人会告诉你什么。试试吧,亲眼看看。经验上,在带有低内存的G1或其他手机上,交换使手机更好,更快地运行。

是的,Android拥有生命周期"任务管理" 内置,但它不是很好。它常规杀死进程当它缺失内存时,并且预期应用程序使用"捆绑" 保存他们的州。重新启动它们,他们以与他们持续的状态重启。

一旦Android确定它需要删除一个过程,它就粗暴地确实强行杀死它。然后,内核可以立即回收过程所需的所有资源,而无需依赖于该应用程序写得很好地写入并响应于有礼貌的退出请求。允许内核立即回收应用程序资源使得更容易避免严重的内存情况。

如果它实际上工作,这将是很好的,并且会比不分青红皂白的交换更好。但是该应用程序并没有真正挽救他们的州;他们只是保存最小量的信息以回到该状态。 (并且一些应用程序甚至没有费令这样做。)回到该状态需要时间。由于Swap实际上保存了一个只需重新加载的应用程序的整个状态,因此它会使应用程序之间切换更快。

如果从浏览器切换到另一个应用程序,例如,浏览器几乎总是被杀死,然后它必须重新加载来自Internet 的整个页面。这比重新加载来自交换的状态的时间更长,如果您在数据计划中,则会浪费您的钱,并在网页动态时导致状态问题。

许多应用程序需要更长的时间开始于它们的开始,或者在重新启动时实际上不会返回相同的状态,因此更好地交换它们的工作。

我猜我对股票系统感到满意的人,请使用他们的手机。

我应该使用cyanogenmod吗?

 

There is definitely a benefit to swapping, despite what everyone else on the Internet will tell you. Try it and see for yourself. Empirically, on a G1 or other phone with low memory, swap makes the phone run better and faster.

Yes, Android has Life Cycle "task management" built in, but it's not very good. It routinely kills processes when it runs out of memory, and the apps are expected to save their state using "Bundles" so that when you restart them, they restart in the same state they were last in.

Once Android determines that it needs to remove a process, it does this brutally, simply force-killing it. The kernel can then immediately reclaim all resources needed by the process, without relying on that application being well written and responsive to a polite request to exit. Allowing the kernel to immediately reclaim application resources makes it a lot easier to avoid serious out of memory situations.

This would be great if it actually worked, and would be better than indiscriminate swap. But the apps don't really save their state; they just save the minimal amount of information to get back to that state. (And some apps don't even bother to do this.) Getting back to that state takes time. Since swap actually saves the entire state of the app, which just has to be reloaded, it makes switching between apps much faster.

If you switch to another app from the browser, for instance, the browser almost always gets killed, and then it has to reload the entire page from the Internet when you switch back to it. This takes wayyyy longer than reloading the state from swap, wastes your money if you're on a data plan, and causes state problems when the web page is dynamic.

Many apps take much longer to start up than they should, or don't actually return to the same state when they're restarted, so swapping them out works better.

I'm guessing the people who are happy with the stock system use their phones differently.

Should I use a swap partition with Cyanogenmod?

 
 
     
     
2
 
vote

我有一个香料Mi-435(仅在印度销售),只有340米的RAM。地狱ya,交换文件有助于很多。我的手机在这样的低RAM上运行IC,肯定输入了许多内存状态,并且有交换文件有助于很多。当不在主动使用时转移所有应用程序状态以交换。这为我的手机室提供了更多的应用程序和RAM Hungry Apps,以便平稳地运行比以前更少的滞后。虽然在打开我以前使用的应用程序时出现问题。加载其状态需要时间,因为SD比船上的高速RAM更慢。但是,交换选项对于如此较少的RAM更好。我建议交换小于512米的RAM分区,但不超过512米。

希望它有用。

 

I have a Spice mi-435(only sold in India) which has a RAM of only 340M. Hell ya, the swap files help a lot. My phone runs ICS on such low RAM and definitely entered many out of memory states and there the swap file helps a lot. All the application states are transfered to swap when not in active use. This gives my phone room for more applications and RAM hungry apps to run smoothly with much much much less lag than before. Though there comes a problem when i open the app i have been using before. It takes time to load its state as the SD is much more slower than the high speed RAM on board. But, the swap option is better for so less RAM. I would recommend to swap partition for RAM less than 512M but not for more than 512M.

Hope it is helpful.

 
 
1
 
vote

交换文件甚至有助于更高RAM的系统。我的四核1GB RAM 7英寸平板电脑在UHS-1 Micro SD卡上夹在2GB交换中的主要多任务提升。当然,记忆的价格迅速下降,即使在不断的写入时,NAND Flash应该持续到持续数年。

im基本上是意见,因为性能差异是如此激进,可能有任何不到真正大量的RAM的人应该这样做。事实上,它应该是Android中的标准选项(以及更大的应用程序缓存,以及适当的互联网缓存)。

我的意思是你有一个64-128GB的微SD(UHS-1),甚至是今年出现的UHS-2,加上16-64GB内部NAND,通常是"快速" 的NAND,这是一种原始SSD甚至是SSD,正如在Windows Slates上使用的那样 - 您不完全填充大量高速空间。速度只能使用视频,或将应用程序加载到内存中 - 这正是这里的使用。

当然,理想情况下,制造商将更多地关注RAM,而不是分辨率或额外的核心,因为显然系统速度从较高的RAM中有很多效益 - 并且它们也应该也应该提高内部存储的速度(如切换到完整SSD类型系统,或至少在"快速" NAND中。但在平均的时间,而高分辨率倾向于导致所有设备中的RAM缺陷,交换文件,并将其缓存到合理的Snappy外部SD会产生很多意义。

我确实很高兴看到一些浏览器也保持更富有缓存,大多数浏览器都是慢速或低的功能,很少有快速和全面的特色 - 而且部分是因为内部驱动器上的应用程序缓存的空间很小。它们旨在在低内存和存储环境中运行,并且整个故事正在发生变化。即使RAM不像它应该一样切换,肯定是,它可以在UHS-1标准(或今年发布的UHS-2)上快速漂亮,即使它不是"快速"或SSD。

和外部内存的成本,是花生真的,即使对于较高的容量UHS-1也是如此。至少一个64GB UHS-1非常实惠(我是50美元,但它会减少USD),比设备便宜得多,32 GB和下面基本上是几个贸易人。

真正从桌面中学到的大量课程,特别是现在规格越来越高 - 最慢的性能链接是从存储到RAM的加载。你可以做的越多,减轻这种情况,更好。

 

Swap file helps even on systems with higher RAM. My quad core 1gb ram 7 inch tablet gets a major multi-tasking boost from chucking in a 2gb swap, on the uhs-1 micro sd card. And of course, the price of memory goes down rapidly, and even at constant write, nand flash is supposed to last years.

Im basically of the opinion, because the performance difference is so radical, that probably anyone with less than a really large amount of RAM should be doing this. In fact it should probably come as a standard option in android (along with bigger app caches, and a proper sized internet cache).

I mean you have a 64-128gb micro sd (uhs-1), or even the uhs-2 that came out this year, plus a 16-64gb internal nand, often "fast" nand, which is a kind of primitive ssd or even SSD, as are used on windows slates - your not exactly filling all that high speed space up with much. The speed only really comes into play with video, or loading apps into memory - which is exactly the use here.

Of course ideally, manufacturers would focus more on RAM, than resolution or extra cores, because clearly the system speed benefits a lot from higher ram - and they should probably also up the speed of the internal storage too (like switching to full ssd type systems, or at minimum "fast" nand. But in the mean time, while high resolutions tend to cause a sort of RAM deficit in all devices, a swap file, and caching to a reasonably snappy external sd makes a lot of sense.

Indeed it would be nice to see some browsers keep fuller caching too, most browsers are either slow, or low feature, rarely fast and full featured - and thats partly because the space for the app cache on the internal drive is tiny. They are designed to operate within a low memory and storage environment, and that whole story is changing. Even if the ram isn't up to chop as much as it should be, the storage certainly is, and it can be pretty darn fast on UHS-1 standards (or the uhs-2 released this year), even if its not "fast" or ssd.

And the cost of external memory, is peanuts really, even for higher capacity uhs-1. At least a 64gb uhs-1 is perfectly affordable (50 bucks where I am, but it would be less USD), much cheaper than the device, and 32 gb and under is basically a couple of tenners.

Plenty of lessons to be learned from the desktop really, especially now the specs are getting higher - the slowest performance link is loading from storage to ram. The more you can do to mitigate that, the better.

 
 

相关问题

20  交换分区/文件如何影响系统?  ( How will a swap partition file affect the system ) 
有朋友告诉我,他们的Android手机都非常小(小于100MB)进行定期的应用程序可用内存,因为操作系统和一些非killable服务占据了大部分内存。例如,一个带512MB的手机只显示90MB可用内存,因此只有2-3个应用程序可以同时运行。 我想知道创建交换分区/文件是否有帮助,但我在网络上看到了混合意见,我不确定该...

0  Android低内存:如何在无法打开任何内容时进行工厂重置我的手机  ( Android low memory how to do factory reset of my phone when it wont open anyth ) 
我的Android手机一直在给我一个屏幕顶部的"低记忆" 错误。我想卸载密集的应用程序或甚至进行恢复出厂设置(在线教程之后),但即使我从家庭屏幕上打开导航器或其他任何其他内容,屏幕也会变为空白黑色,然后恢复主屏幕后而。 我在网上找到的所有教程到修复错误,找到哪些应用程序正在讨论内存,到删除缓存和历史,或 Factor...

2  如何手动将内存添加到Android仿真器?  ( How can i manually add memory to the android emulator ) 
我打算购买一个Android手机,但我想尝试使用Android仿真器的Android市场中的应用程序。我已经下载了许多应用程序,并因为低内存而达到了我可以下载的最大应用程序。我的问题是如何手动将内存添加到仿真器? ...

1  谷歌驱动器到Instagram文件位置?  ( Google drive to instagram file location ) 
我有一个Samsung Galaxy S6带有Android 7.0,拥有大约29GB的32GB内存。然后,我试图将Google Drive的大型视频文件(3 + GB)发布到我的Instagram中,但它陷入了Instagram的"加载" 屏幕,相当长。我想也许系统正在挂起,所以我退出并关闭了所有手机应用程序。从那...

9  让家庭发射器被杀死  ( Keep the home launcher from being killed ) 
我有一个摩托罗拉里程碑,我来了解它具有相对较低的内存(运行时内存,而不是存储容量)。此问题的问题是,每当太多应用程序想要在后台运行时,Android系统就会开始杀死东西,并与我的里程碑很容易发生。 这不是那么糟糕,如果它不适合Android似乎认为家庭发射器是所有(这是荒谬的错误)的最不重要的应用程序。例如,目前我...

-5  如何使移动设备强大的PC /服务器?  ( How to make mobile device powerful as pc server ) 
我们可以以某种方式使用我们的PC连接移动设备,并在连接的移动设备上使用PC的RAM,CPU等,或者可以有一个强大的外部RAM和用于移动设备的处理器吗? ...

10  2 GB RAM或3 GB RAM,真的很重要吗?  ( 2 gb ram or 3 gb ram does it really matter ) 
我正在考虑购买新的 xiaomi redmi 3s 在最近推出的电话印度。这将是我的第一个Android手机。现在,手机配有两种变体,RedMI 3S,带有2 GB RAM和Redmi 3 S的素,带有3 GB RAM,都配有Qualcomm®Canndragon430 除了使用手指打印传感器附带的Prime版本外,...

11  你如何看待Android o的内存用法?  ( How do you see memory usage in android o ) 
在Android oreo之前,我可以通过进入 Settings &gt来查看内存使用情况; Memory 但是由于升级到Android O.现在有没有办法或者它已经完全删除了 ...

1  如何调查内存使用量?  ( How do i investigate the memory usage ) 
我是一个micromax a74,with(rooted)Android 4.2.2。最近我面临着一些应用程序的崩溃并开始分析RAM的使用。 设置&gt; apps&gt;运行没有帮助: 有时我发现只有2 MB免费! 我想知道哪个应用程序正在消耗内存? 我还尝试过 top -n 1 -m 8 : 但我...

0  向Android添加交换支持  ( Add swap support to android ) 
我拥有三星Galaxy GT-I9082,相信我,由于其低RAM i.e I. i I. I I. I I. I I. I I. I I. I I. I. I I. I. I I. I. I I. i.e非常慢。我已经从XDA安装了Lineage OS的自定义ROM,但它仍然不支持交换,这是增加智能手机RAM的唯一方...




© 2022 it.wenda123.org All Rights Reserved. 问答之家 版权所有