程序如何 used/consumed 磁盘内存?

How is disk memory being used/consumed by programs?

一个虚拟问题: 最近我的磁盘 运行 内存不足: 我不断收到 java.OutOfMemoryError、java 堆 space,后来我的 Virtual Box 遇到了 "Not Enough Free Space available on disk" 错误。 后来发现我的256GB SSD已经快用完了consumed/used.

所以我想知道 运行 程序如何消耗我的 memory/disk 使用量? 这是如何运作的? 我知道这背后的基础知识,在 heap/stack 上分配 space,然后在使用后释放它们。 (如果我错了纠正我。) 但是如果是这样的话,那么磁盘应该不会用完吧? (如果我不在我的桌面上添加任何其他东西,只将它用于 运行 一定数量的程序)

我真的很想了解 运行ning 程序如何 disk/memory consumed/used。 如果之前有人问过这个问题,请将它与那个问题联系起来。 我很抱歉这个愚蠢的问题,但我相信它会对像我这样的程序员有帮助。

感谢您使它更清晰。 Q1:为什么程序会占用磁盘space? A2:"java.OutOfMemoryError, java heap space" 是如何产生的?与记忆有关,是吗?

为什么程序会占用磁盘 space?

I know the basics behind this, allocating space on a heap/stack, then deallocating them after use. But if this is the case, then the disk should not be used up, right?

其实是可以用完的。
如果您进程的虚拟内存中的分配恰好映射到磁盘上的页面文件,并且您的页面文件大小设置为由操作系统管理,则内存分配会消耗硬盘 space。

如果您想了解更多关于内存映射的信息,这里有一个很好的问题: Understanding Virtual Address, Virtual Memory and Paging

页面文件增长实际上并不是对您的分配的直接响应,更多是对新的当前提交大小接近保留大小的响应。如果您想了解更多关于此过程的信息(提交与保留、堆栈扩展等),我建议您阅读 Pushing the Limits of Windows: Physical Memory

为什么会出现java.OutOfMemoryError?

http://docs.oracle.com/javase/7/docs/api/java/lang/OutOfMemoryError.html

Thrown when the Java Virtual Machine cannot allocate an object because it is out of memory, and no more memory could be made available by the garbage collector.

发生这种情况通常是因为您的页面文件太小或磁盘太满。

另请参阅:

  • How to deal with "java.lang.OutOfMemoryError: Java heap space" error (64MB heap size)
  • java.lang.OutOfMemoryError: Java heap space