日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

[Erlang危机](5.1.1)内存

發布時間:2023/12/20 编程问答 21 豆豆
生活随笔 收集整理的這篇文章主要介紹了 [Erlang危机](5.1.1)内存 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

原創文章,轉載請注明出處:server非業余研究http://blog.csdn.net/erlib 作者Sunface聯系郵箱:cto@188.com


Memory

The memory reported by the Erlang VM in most tools will be a variant of what is reported by?erlang:memory()?:

Erlang VM大多數檢測內存的工具都是通過erlang:memory()來實現的。

-------------------------------------------------------------------------------------
1> erlang:memory().
[{total,13772400},
{processes,4390232},
{processes_used,4390112},
{system,9382168},
{atom,194289},
{atom_used,173419},
{binary,979264},
{code,4026603},
{ets,305920}]
--------------------------------------------------------------------------------------

?This requires some explaining.
?First of all, all the values returned are in bytes, and they represent memory allocated (memory actively used by the Erlang VM, not the memory set aside by the operating system for the Erlang VM). It will sooner or later look much smaller than what the operating system reports.

?這里須要解釋下:
?首先,全部的返回值都是字節(bytes)為單位的,它們表示眼下被分配的內存(Erlang VM實際使用的內存。不是操作系統給Erlang VM分配的內存),所以這個值要比操作系統分配的小非常多。

?The total field contains the sum of the memory used for processes and system (which is incomplete, unless the VM is instrumented!). processes is the memory used by Erlang processes, their stacks and heaps. system is the rest: memory used by ETS tables, atoms in the VM, refc binaries11, and some of the hidden data I mentioned was missing.
?If you want the total amount of memory owned by the virtual machine, as in the amount that will trip system limits (ulimit), this value is more difficult to get from within the VM.
?If you want the data without calling top or htop, you have to dig down into the VM’s memory allocators to find things out12.

?總字段包括了全部進程和系統(除instrumented模式外)的總內存占用大小。返回的processes項是指Erlang進程使用的堆棧總內存。system項就包括其余的:ETS表。VM中的原子,二進制數據11(refc binaries,詳細的可見堅強2002博客 - Sunface),和一些我沒有提及到的隱藏數據。
?假設你想得到VM在操作系統占用的總內存,這個值在訪問系統的限制下(ulimit),非常難從VM內部獲得。
?假設你想不調用top或htop命令來得到數據,你就不得不深入VM內存管理分配來找到你想要的12

?Fortunately, recon has the function recon_alloc:memory/1 to figure it out, where the argument is:
???used?reports the memory that is actively used for allocated Erlang data;
???allocated?reports the memory that is reserved by the VM. It includes the memory used, but also the memory yet-to-be-used but still given by the OS. This is the amount you want if you’re dealing with ulimit and OS-reported values.
???unused?reports the amount of memory reserved by the VM that is not being allocated. Equivalent to allocated-used.
???usage?returns a percentage (0.0 .. 1.0) of used over allocated memory ratios. There are additional options available, but you’ll likely only need them when investigating memory leaks in chapter 7

?只是。非常幸運的是。recon有一個函數:recon_alloc:memory/1能夠解決上述問題,參數例如以下:
? ? ? used:給Erlang data分配的內存?

? ? ? allocated:VM占用的總內存。它包括已使用的內存。也包括還已由OS分配給VM但尚未被分配的內存。假設你在處理ulimit和

OS-reported的值,這個參數就非常實用。

? ? ? unused:OS分配給VM可是尚未被VM分配的那部分內存。

? ? ? ? ?usage:返回各個功能使用內存的百分比。另一些額外的選項,只是你可能僅僅會在第七章的內存泄漏那里使用。

[11] See Section 7.2
[12] See Section 7.3.2

[注11]:參見章節7.2
[注12]:參見章節7.3.2

轉載于:https://www.cnblogs.com/jhcelue/p/6800565.html

總結

以上是生活随笔為你收集整理的[Erlang危机](5.1.1)内存的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。