[Erlang危机](5.1.1)内存
Memory
The memory reported by the Erlang VM in most tools will be a variant of what is reported by?erlang:memory()?:
Erlang VM大多數(shù)檢測(cè)內(nèi)存的工具都是通過erlang:memory()來實(shí)現(xiàn)的。-------------------------------------------------------------------------------------
1> erlang:memory().
[{total,13772400},
{processes,4390232},
{processes_used,4390112},
{system,9382168},
{atom,194289},
{atom_used,173419},
{binary,979264},
{code,4026603},
{ets,305920}]
--------------------------------------------------------------------------------------
?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.?這里須要解釋下:
?首先,全部的返回值都是字節(jié)(bytes)為單位的,它們表示眼下被分配的內(nèi)存(Erlang VM實(shí)際使用的內(nèi)存。不是操作系統(tǒng)給Erlang VM分配的內(nèi)存),所以這個(gè)值要比操作系統(tǒng)分配的小非常多。
?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.
?假設(shè)你想得到VM在操作系統(tǒng)占用的總內(nèi)存,這個(gè)值在訪問系統(tǒng)的限制下(ulimit),非常難從VM內(nèi)部獲得。
?假設(shè)你想不調(diào)用top或htop命令來得到數(shù)據(jù),你就不得不深入VM內(nèi)存管理分配來找到你想要的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?只是。非常幸運(yùn)的是。recon有一個(gè)函數(shù):recon_alloc:memory/1能夠解決上述問題,參數(shù)例如以下:
? ? ? used:給Erlang data分配的內(nèi)存?
? ? ? allocated:VM占用的總內(nèi)存。它包括已使用的內(nèi)存。也包括還已由OS分配給VM但尚未被分配的內(nèi)存。假設(shè)你在處理ulimit和
OS-reported的值,這個(gè)參數(shù)就非常實(shí)用。
? ? ? unused:OS分配給VM可是尚未被VM分配的那部分內(nèi)存。
? ? ? ? ?usage:返回各個(gè)功能使用內(nèi)存的百分比。另一些額外的選項(xiàng),只是你可能僅僅會(huì)在第七章的內(nèi)存泄漏那里使用。
[11] See Section 7.2[12] See Section 7.3.2[注11]:參見章節(jié)7.2
[注12]:參見章節(jié)7.3.2
轉(zhuǎn)載于:https://www.cnblogs.com/jhcelue/p/6800565.html
總結(jié)
以上是生活随笔為你收集整理的[Erlang危机](5.1.1)内存的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 51nod 1258 序列求和 V4
- 下一篇: ZXing二维码和条形码