Nodejs进程可以使用比可用物理内存更多的内存(通过使用交换内存)吗?(Can a Nodejs process uses more memory than the available physic

编程入门 行业动态 更新时间:2024-10-24 06:35:50
Nodejs进程可以使用比可用物理内存更多的内存(通过使用交换内存)吗?(Can a Nodejs process uses more memory than the available physical memory (by using swap memory)?)

我正在使用Nodejs。 我计划增加Nodejs应用程序的内存限制。

谷歌搜索时,我发现这篇文章: 增加Node.js内存限制 。

作者说他的服务器只有8GB的物理内存,但他的Nodejs进程使用了28GB的内存。 我假设它正在使用physical + swap内存。 文章还提到着名的Nodejs框架的开发人员对他的Nodej使用了15GB内存限制。

我试图从其他编程语言中搜索一些示例。 在Java中,似乎将交换内存用于JVM堆并不是一个好主意。 参考这篇文章: 增加交换大小如何允许我增加堆大小? ,使用交换内存进行JVM堆会产生很大的问题。

我不确定JVM GC和Nodejs GC之间是否存在任何差异。

Nodejs进程可以使用比可用物理内存更多的内存(通过使用交换内存)吗?

I am using Nodejs. I am planning to increase the memory limit of a Nodejs application.

While googling, I found this article: Increasing Node.js memory limits.

The author says his server only has 8GB of physical memory, but his Nodejs process is using 28GB of memory. I assume that it is using physical + swap memory. The article also mentioned that the developer of a famous Nodejs framework uses 15GB memory limit for his Nodejs.

I have tried to search for some examples from other programming languages. In Java, it seems that it is not a good idea to use swap memory for JVM heap. Referring to this article: How increasing swap size allow me to increase the heap size?, using swap memory for JVM heap will create big problems.

I am not sure whether there is any difference between the JVM GC and the Nodejs GC.

Can a Nodejs process uses more memory than the available physical memory (by using swap memory)?

最满意答案

Nodejs进程可以使用比可用物理内存更多的内存(通过使用交换内存)吗?

是的,它可以。 像任何其他过程一样。 它由操作系统管理。 该过程要求新页面,它甚至不知道它是否被交换。

但是,我不推荐它,因为它可能导致性能下降。 磁盘(甚至SSD)比RAM慢几个数量级。 就个人而言,我个人并不喜欢在我的系统上使用任何交换内存。 不幸的是,在Linux上它意味着我无法暂停到磁盘,但我可以忍受。

检查内存使用情况时实际看到的内容并不总是那么明显。 某些共享库可以同时映射到多个进程,您看到的用法并不总是真实的。 一个过程也可以要求大量的内存,但这并不意味着它得到了它。 实际物理内存(RAM或交换)可以在第一次实际访问给定页面时进行映射,而不是在请求时进行映射。 它完成了页面错误。

有关详情,请参阅:

https://en.wikipedia.org/wiki/Virtual_memory

Can a Nodejs process uses more memory than the available physical memory (by using swap memory)?

Yes, it can. Like any other process. It is managed by the OS. The process asks for a new page and it doesn't even know if it's swapped or not.

I wouldn't recommend it, though, as it can lead to degraded performance. Disks (even SSD) are orders of magnitude slower than RAM. Personally I don't like using any swap memory at all on my systems for exactly that reason. Unfortunately on Linux it means that I can't suspend to disk but I can live with that.

What you actually see when you check the memory usage is not always that obvious. Some shared libraries can be mapped to several processes at the same time and the usage you see is not always real. Also a process can ask for a lot of memory but it doesn't mean it gets it. The real physical memory (RAM or swap) can be mapped when a given page is actually accessed for the first time, not when it is requested. It's done with page faults.

For more info see:

https://en.wikipedia.org/wiki/Virtual_memory

更多推荐

本文发布于:2023-07-16 09:59:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1126857.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:内存   可以使用   进程   物理   更多

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!