mac关闭虚拟内存

Your Mac comes with a set amount of physical memory applications can use. Your running programs, open files, and other data your Mac is actively working with are stored in this physical memory. But that’s a simplification—applications can also use “virtual memory”, which your Mac can compress and temporarily store on disk.

您的Mac随附了可以使用的一定数量的物理内存。 Mac正在使用的正在运行的程序,打开的文件以及其他数据都存储在此物理内存中。 但这只是一种简化-应用程序还可以使用“虚拟内存”,Mac可以将其压缩并临时存储在磁盘上。

There’s no official way to disable virtual memory on a modern Mac, although this was possible in the days before Mac OS X—now named macOS—was released. While it may be possible to hack your system to prevent your Mac from storing virtual memory on disk, you shouldn’t do this.

尽管在Mac OS X(现在称为macOS)发布之前的几天里,可以在现代Mac上禁用虚拟内存,但是没有官方的方法。 虽然可能会入侵您的系统以阻止Mac将虚拟内存存储在磁盘上,但您不应该这样做。

什么是虚拟内存? (What Is Virtual Memory?)

While your Mac only has a limited amount of physical memory, it exposes a larger area of available virtual memory to running programs. For example, even if you have a Mac with 8 GB of RAM, every 32-bit process on your Mac is given 4 GB of available address space it can use. Every 64-bit process is given about 18 exabytes—that’s 18 billion gigabytes—of space it can work with.

尽管Mac的物理内存量有限,但它会将较大的可用虚拟内存区域暴露给正在运行的程序。 例如,即使您的Mac具有8 GB的RAM,Mac上的每个32位进程也会获得4 GB的可用地址空间。 每个64位进程都可以使用大约18艾字节(即180亿千兆字节)的空间。

Applications are free to use as much memory as they want within these limitations. When your physical memory fills up, macOS automatically “pages out” data that isn’t actively being used, storing it on your Mac’s internal drive. When the data is needed again, it’s transferred back to RAM. This is slower than simply keeping the data in RAM all the time, but it allows for the system to transparently just “keep working”. If Macs couldn’t store virtual memory data on disk, you’d see messages asking you to close a program to continue.

在这些限制内,应用程序可以自由使用所需的内存。 当您的物理内存已满时,macOS会自动“调出”未被积极使用的数据,并将其存储在Mac的内部驱动器中。 当再次需要数据时,会将其传输回RAM。 这比始终将数据始终保持在RAM中要慢,但是它允许系统透明地只是“保持工作”。 如果Mac无法在磁盘上存储虚拟内存数据,则会看到消息,要求您关闭程序以继续。

This is basically the same thing as the page file on Windows, and the swap space on Linux and other UNIX-like operating systems. In fact, macOS is a UNIX-like operating system itself.

这基本上与Windows上的页面文件和Linux和其他类似UNIX的操作系统上的交换空间相同 。 实际上,macOS本身就是类UNIX的操作系统。

Modern versions of macOS actually go through even more trouble to avoid paging out data to the disk, compressing data stored in memory as much as possible before paging it out.

实际上,现代版本的macOS会遇到更多麻烦,以避免将数据分页到磁盘,在分页之前尽可能多地压缩存储在内存中的数据 。

它存储在哪里? (Where Is It Stored?)

Virtual memory data is stored in the /private/var/vm directory on your Mac’s internal storage if it has been paged to disk. The data is stored in one or more files named “swapfile” and ending with a number.

如果虚拟内存数据已分页到磁盘,则存储在Mac内部存储器的/private/var/vm目录中。 数据存储在一个或多个名为“ swapfile”的文件中,并以数字结尾。

Most UNIX-like operating systems use a separate partition for the swap file, permanently allocating part of your storage to swap space. Apple’s macOS does not do this. Instead, it stores the swapfile files on your system storage drive. If applications don’t need additional virtual memory, these files won’t use much space. If applications need more virtual memory, these files will grow in size as needed—and then shrink back down when they don’t need be large anymore.

大多数类似UNIX的操作系统都为交换文件使用单独的分区,从而将部分存储永久分配给交换空间。 苹果的macOS不会这样做。 而是将交换文件文件存储在系统存储驱动器上。 如果应用程序不需要额外的虚拟内存,则这些文件不会占用太多空间。 如果应用程序需要更多的虚拟内存,这些文件将根据需要增大大小,然后在不再需要大文件时缩小它们。

This directory also contains the “sleepimage” file, which stores the contents of your Mac’s RAM on disk when it hibernates. This allows the Mac to save its state—including all your open applications and files—while shutting down and not using any power.

该目录还包含“ sleepimage”文件,该文件在Hibernate时将Mac RAM的内容存储在磁盘上。 这样,Mac可以在关闭且不使用任何电源的情况下保存其状态(包括所有打开的应用程序和文件)。

To view the contents of this directory and see how much space these files are currently using on disk, you can open a Terminal window and run the following command. (To open a Terminal window, press Command+Space to open Spotlight search, type “Terminal”, and press Enter.)

要查看此目录的内容并查看这些文件当前在磁盘上使用了多少空间,可以打开“终端”窗口并运行以下命令。 (要打开终端窗口,请按Command + Space打开Spotlight搜索,键入“ Terminal”,然后按Enter。)

ls -lh /private/var/vm

In the screenshot below, we can see that each of these files is 1 GB in size on my Mac.

在下面的屏幕截图中,我们可以看到Mac上每个文件的大小均为1 GB。

为什么不应该禁用虚拟内存 (Why You Shouldn’t Disable Virtual Memory)

You really shouldn’t try to disable this feature. The macOS operating system and running applications expect it to be enabled. In fact, Apple’s official documentation says “Both OS X and iOS include a fully-integrated virtual memory system that you cannot turn off; it is always on.”

您确实不应该尝试禁用此功能。 macOS操作系统和正在运行的应用程序希望将其启用。 实际上,苹果公司的官方文档说: “ OS X和iOS都包含一个完全集成的虚拟内存系统,您无法关闭它; 它总是打开。”

However, it is technically possible to disable the backing store—that is, those swapfiles on disk—on macOS. This involves disabling System Integrity Protection before telling your Mac not to run the dynamic_pager system daemon and then deleting the swapfiles. We won’t provide the relevant commands for doing this here, as we don’t recommend anyone do this.

但是,从技术上讲,可以在macOS上禁用后备存储(即磁盘上的那些交换文件)。 这涉及在告诉Mac不要运行dynamic_pager系统守护程序之前,先禁用系统完整性保护 ,然后删除交换文件。 我们不会在此处提供执行此操作的相关命令,因为我们不建议任何人这样做。

The macOS operating system and the applications running on it expect the virtual memory system to work properly. If your physical memory fills up and the Mac operating system can’t page data out to disk, one of two bad things will happen: Either you’ll see a prompt telling you to quit one or more applications to continue, or applications will crash and you may experience general system instability.

macOS操作系统及其上运行的应用程序期望虚拟内存系统正常运行。 如果您的物理内存已满,并且Mac操作系统无法将数据分页到磁盘,则会发生以下两种不良情况之一:要么看到提示您退出一个或多个应用程序以继续运行的提示,否则应用程序将崩溃并且您可能会遇到一般系统不稳定的情况。

Yes, even if you have 16 GB or more of RAM, it may sometimes fill up—especially if you run demanding professional applications like video, audio, or image editors that need to store a lot of data in memory. Leave it alone.

是的,即使您有16 GB或更多的RAM,有时它也可能会填满-特别是如果您运行要求严格的专业应用程序,例如视频,音频或图像编辑器,需要在内存中存储大量数据。 不要管它。

不用担心磁盘空间或SSD (Don’t Worry About Disk Space, or Your SSD)

There are two reasons why people might want to disable the virtual memory feature and remove the swapfile files from disk.

人们可能要禁用虚拟内存功能并从磁盘中删除交换文件文件有两个原因。

First, you may be concerned about disk space usage. You may want to get rid of these files to free up some space. Well, we wouldn’t worry about it. These files don’t waste a large amount of space on disk. If your Mac doesn’t need much virtual memory, they’ll be tiny. On our MacBook Air with only 4 GB of RAM, we noticed a swapfile file using about 1 GB of space—that’s it.

首先,您可能会担心磁盘空间的使用。 您可能希望摆脱这些文件以释放一些空间。 好吧,我们不用担心。 这些文件不会在磁盘上浪费大量空间。 如果您的Mac不需要太多虚拟内存,它们将很小。 在只有4 GB RAM的MacBook Air上,我们注意到一个交换文件文件使用了大约1 GB的空间。

If they are using a lot of space, that’s because the programs you have open need it. Try closing demanding programs—or even rebooting—and the swapfile files should shrink and stop using space. Your Mac only uses disk space when necessary, so you aren’t losing anything.

如果他们使用大量空间,那是因为您打开的程序需要它。 尝试关闭要求苛刻的程序(甚至重新启动),交换文件文件应缩小并停止使用空间。 Mac仅在必要时使用磁盘空间,因此您不会丢失任何东西。

If the virtual memory files are always very large, that’s a sign you need more RAM in your Mac, not that you need to disable the virtual memory feature. (You can see how much physical memory your Mac has by clicking Apple menu > About This Mac and reading what it says next to “Memory”.)

如果虚拟内存文件始终很大,则表明您的Mac需要更多RAM,而不是需要禁用虚拟内存功能。 (您可以通过单击Apple菜单>关于本Mac,然后阅读“内存”旁边的内容来查看Mac的物理内存量。)

The other concern is wear of your Mac’s internal solid-state drive. Many people are worried that excess writes to a solid-state drive could reduce its lifespan and cause problems. This is true in theory, but in practice, this concern is generally overblown, and left over from the days when SSDs had far less longevity. Modern SSDs should last a good long time, even with features like this enabled. macOS won’t quickly wear down your SSD just because you leave a default system feature enabled—in fact, something else in your Mac will probably die before your SSD.

另一个问题是Mac内部固态驱动器的磨损。 许多人担心过多写入固态驱动器会缩短其使用寿命并引起问题。 从理论上讲这是正确的,但实际上,这种担忧通常被夸大了,并且从SSD使用寿命长得多的时代就遗忘了。 即使启用了此类功能,现代SSD也应持续很长时间。 macOS不会仅仅因为您启用了默认系统功能而立即耗尽SSD —实际上,Mac中的其他内容可能会在SSD之前消失。

In other words, don’t worry about it. Leave virtual memory be and allow your Mac to work as it was designed to.

换句话说,不用担心。 保留虚拟内存不变,并允许Mac按其设计的方式工作。

翻译自: https://www.howtogeek.com/319151/why-you-shouldnt-turn-off-virtual-memory-on-your-mac/

mac关闭虚拟内存

mac关闭虚拟内存_为什么不应该关闭Mac上的虚拟内存相关推荐

  1. 准考证打印系统关闭怎么办_准考证打印系统关闭怎么办_公务员考录专题网站...

    准考证打印系统关闭怎么办_公务员考录专题网站由国家公务员考试网考试快讯栏目由提供,更多关于国考准考证打印时间,国家公务员考试考试快讯的内容,请关注国家公务员考试网/广东公务员考试网! 请注意!23日0 ...

  2. 准考证打印系统关闭怎么办_准考证打印系统关闭怎么办_广东省人力资源和社会保障厅网站...

    准考证打印系统关闭怎么办_广东省人力资源和社会保障厅网站,更多关于广东事业单位考试准考证打印,事业单位准考证打印的内容,请关注广东事业单位考试网/广东人事考试网! 本次公开招聘考试采取"笔试 ...

  3. mac docker 共享_如何在Docker for Mac中加快共享文件访问

    mac docker 共享 Docker just released a native MacOS runtime environment to run containers on Macs with ...

  4. mac os 触摸屏_为什么没有出现触摸屏Mac

    mac os 触摸屏 Apple will make it easier to developers to port iPhone and iPad apps to the Mac, but that ...

  5. w311m linux驱动下载,腾达W311M无线网卡驱动mac版下载_腾达W311M无线网卡驱动mac版官方下载-太平洋下载中心...

    腾达W311M是一款采用11N无线技术的无线mini usb网卡,这款产品不仅外观小巧功能也非常强大.这里太平洋下载中心给大家提供了腾达W311M无线网卡驱动mac版,如果你的无线网卡设备接入mac设 ...

  6. 虚拟内存架设服务器客户端,怎么在服务器上开虚拟内存

    怎么在服务器上开虚拟内存 内容精选 换一换 迁移任务失败后,目的端系统盘是以SMS为开头的临时系统盘,而非目的端本身系统盘,目的端本身系统盘无法被挂载上去.任务失败后,迁移过程中原有的卸载临时镜像的步 ...

  7. resultset需要关闭吗_旧电脑福音!关闭Windows这些没用的设置,电脑性能至少提升50%!...

    Win10系统一直在更新的路上,但是每一次更新,感觉不是在修复旧Bug,就是在添加新Bug 的路上. 而其他的系统设置也不知道好好整改一下,让我们可以根据自己的喜好,来高效优化Windows系统的使用 ...

  8. java关闭服务_实现优雅地关闭Docker中的java服务

    时至今日,Docker在项目中的应用越来越普遍了,但往往会遭遇一些麻烦,比如说,有几个请求至Docker中的服务,发起了事务处理业务,但每个事务完成可能需要1-5分钟,而此时我们正要将Docker停机 ...

  9. java关闭端口_使用java代码关闭指定端口的程序-windows

    转载请请在页首注明作者与出处 一:问题由史 今天遇到一个问题,就是在实现自动化灾备的时候,发现原有死掉的程序没有完全关闭,当然这都不是本文的重点,重点是这个时候,我得把它完全关闭,所以才有了这篇文章. ...

  10. 使用python软件如何关闭弹窗_如何通过按钮关闭Kivy弹出窗口?

    我有一个用Kivy创建的弹出窗口,其中包含2个按钮.用户可以通过按弹出区域之外的按钮(auto_dismission=True)或单击"否"按钮来关闭弹出窗口. 选择"是 ...

最新文章

  1. php statements,PHP PDOStatement::setAttribute讲解
  2. LAMP编译安装之———httpd
  3. Tungsten Fabric SDN — 软件项目编译与打包
  4. 快速幂模板(java)
  5. leetcode:位操作
  6. 在服务器上安装网站环境,如何在服务器上搭建JSP环境,需要安装哪些软件?
  7. slq2000数据库升级到sql2012
  8. 顺序表基本操作在主函数中的实现
  9. Mysql复制-Slave库设置复制延迟
  10. TypeScript 简介与优势
  11. 代码自动生成工具的补充
  12. 2015-2020年各类国际会议与期刊基于图像的三维对象重建论文综述(5)——Leveraging other clues
  13. [摘录]调动员工积极性的七个关键
  14. solidworks图纸模板添加_如何建立符合国标的SolidWorks工程图模板
  15. android实现弹框动画,android对话框弹出方式动画
  16. JUCE学习笔记08-合成器(一)振荡器与包络发生器
  17. 海量固定资产如何进行盘点?
  18. Bootstrap 警告框组件 + 退出按钮样式 实现一个可退出的警告框
  19. excel sumifs()对多列求和
  20. c语言美元转换人民币的程序,【其它】编程题: 1.编写一个人民币和美元的双向汇率转换程序,实现美元和人民币转换,汇率:1美元=6.92人民币...

热门文章

  1. word里双横线怎么打_word双下划线怎么打出来
  2. ps里面的css,PS图层样式详解(上)
  3. Postgresql去掉某个字段多余的空格
  4. pyodbc 测试连接 SQL Server 数据库
  5. matlab实现隐函数求偏导数(impldiff函数)
  6. 「沙龙回顾」从技术演进角度看猫眼电影
  7. Python爬虫(一)--爬取猫眼Top100排行
  8. JavaScript 全栈工程师培训教程(来自阮一峰)
  9. excel选中行变色
  10. 计算机Wor表格制作斜线表头,Word文档里怎么画表格斜线表头