原文地址:
http://erlang.org/faq/how_do_i.html#5.15
Memory consumption is a bit of a tricky issue in Erlang. Usually, you don't need to worry about it because the garbage collector looks after memory management for you. But, when things go wrong, there are several sources of information. Starting from the most general:
Some operating systems provide detailed information about process memory use with tools like top, ps or the linux /proc filesystem:
cat /proc/5898/status
VmSize: 7660 kB
VmLck: 0 kB
VmRSS: 5408 kB
VmData: 4204 kB
VmStk: 20 kB
VmExe: 576 kB
VmLib: 2032 kB
This gives you a rock-solid upper-bound on the amount of memory the entire Erlang system is using.
erlang:system_info reports interesting things about some globally allocated structures in bytes:
3> erlang:system_info(allocated_areas).
[{static,390265},
{atom_space,65544,49097},
{binary,13866},
{atom_table,30885},
{module_table,944},
{export_table,16064},
{register_table,240},
{loaded_code,1456353},
{process_desc,16560,15732},
{table_desc,1120,1008},
{link_desc,6480,5688},
{atom_desc,107520,107064},
{export_desc,95200,95080},
{module_desc,4800,4520},
{preg_desc,640,608},
{mesg_desc,960,0},
{plist_desc,0,0},
{fixed_deletion_desc,0,0}]
Information about individual processes can be obtained from erlang:process_info/1 or erlang:process_info/2:
2> erlang:process_info(self(), memory).
{memory,1244}
The shell's i() and the pman tool also give useful overview information.
Don't expect the sum of the results from process_info and system_info to add up to the total memory use reported by the operating system. The Erlang runtime also uses memory for other things.
A typical approach when you suspect you have memory problems is
1. Confirm that there really is a memory problem by checking that memory use as reported by the operating system is unexpectedly high.
2. Use pman or the shell's i() command to make sure there isn't an out-of-control erlang process on the system. Out-of-control processes often have enormous message queues. A common reason for Erlang processes to get unexpectedly large is an endlessly looping function which isn't tail recursive.
3. Check the amount of memory used for binaries (reported by system_info). Normal data in Erlang is put on the process heap, which is garbage collected. Large binaries, on the other hand, are reference counted. This has two interesting consequences. Firstly, binaries don't count towards a process' memory use. Secondly, a lot of memory can be allocated in binaries without causing a process' heap to grow much. If the heap doesn't grow, it's likely that there won't be a garbage collection, which may cause binaries to hang around longer than expected. A strategically-placed call to erlang:garbage_collect() will help.
4. If all of the above have failed to find the problem, start the Erlang runtime system with the -instr switch.
分享到:
相关推荐
### Terence Tao - An Introduction to Measure Theory #### 知识点概述 本书由著名数学家陶哲轩(Terence Tao)编写,旨在为读者提供一套关于测度论的基础理论介绍。该书作为陶哲轩博客文章及讲义的汇总,不仅...
标题中的"S-measure(matlab)_S-measure_libraryzsp_"提到了S-measure,这是一个在图像分析和图形检测领域中使用的评价指标。S-measure,全称Structural Similarity Measure,是针对图像分割结果的质量评估工具,它在...
Execute, manage, and measure Intelligent Systems in practiceCreate intelligence: Use different approaches, including machine learningOrchestrate an Intelligent System: Bring the parts together ...
• Measure the input and output signals on page 1-7 from your system in time or frequency domain. • Select a model structure on page 1-9. • Apply an estimation method on page 1-10 to estimate value ...
### 近似熵作为系统复杂度的衡量标准 #### 概述 本文档探讨了近似熵(Approximate Entropy, ApEn)作为一种评估系统复杂性的有效工具,并对其理论基础、计算方法及其在不同背景下的应用进行了深入分析。...
本手册是 FARO Technologies Inc. 发布的 CAM2 Measure v10 - FaroArm 培训手册,旨在为使用 FARO CAM2 Measure 的用户提供系统化的培训。该手册分为多个模块,涵盖了 CAM2 Measure 的核心原理、测量策略和技巧,并...
method for deriving decision-making rules from an information system is given by an example. An approach to fuzzy measures of knowledge is proposed by applying VPRS to fuzzy sets. Some properties of ...
Although a system having less than 2 GB of physical memory can be booted using the /3G switch, in most cases this is ill-advised. If you restart with the 3 GB switch, also known as 4-Gig Tuning, the ...
使用 GPU 实现的一键快速评估显着性对象检测,包括MAE、Max F-measure、S-measure、E-measure。 代码从可从http://dpfan.net/ 获得的 matlab 版本重新实现 使用 pytorch 实现 GPU 可以更容易地嵌入到 eval 代码中...
这篇文章的标题和描述告诉我们,文章研究的主题是基于人眼视觉系统的图像增强技术以及对数对比度度量。文章中提出了一种全新的图像增强算法,这种算法能够在保持边缘细节的同时,对不同光照条件下的图像进行对比度...
Distortion measure plays an important role in audio ste- ganalysis - the analysis and classi¯cation method of determining if an audio medium is carrying hidden information. In this paper, we propose...
CPU, FPU and memory benchmarks are available to measure the actual system performance and compare it to previous states or other systems. Furthermore, complete software, operating system and security...
Sketch Measure 插件Sketch Measure 插件Sketch Measure 插件Sketch Measure 插件Sketch Measure 插件Sketch Measure 插件Sketch Measure 插件Sketch Measure 插件Sketch Measure 插件Sketch Measure 插件Sketch ...
A visual memory scale (VMS) Designed to measure short-term visual recognition memory in 5- and 6-year-old children 152 CHARLES K. MILLEH. AND NORMAN M. CHANSKY and the manner in which they can ...
SBM模型,即基于松弛变量的非径向、非角度的Slacks-based Measure模型,提供了一种解决这一问题的有效方法。该模型在评估效率时考虑了松弛变量,即实际产出与生产可能性集合前沿面之间的差距,能够更准确地处理DMUs...