<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html xmlns:fn="http://www.w3.org/2005/02/xpath-functions"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link rel="stylesheet" href="../../../../doc/otp_doc.css" type="text/css"> <title>Erlang -- instrument</title> </head> <body bgcolor="white" text="#000000" link="#0000ff" vlink="#ff00ff" alink="#ff0000"><div id="container"> <script id="js" type="text/javascript" language="JavaScript" src="../../../../doc/js/flipmenu/flipmenu.js"></script><script id="js2" type="text/javascript" src="../../../../doc/js/erlresolvelinks.js"></script><script language="JavaScript" type="text/javascript"> <!-- function getWinHeight() { var myHeight = 0; if( typeof( window.innerHeight ) == 'number' ) { //Non-IE myHeight = window.innerHeight; } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { //IE 6+ in 'standards compliant mode' myHeight = document.documentElement.clientHeight; } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { //IE 4 compatible myHeight = document.body.clientHeight; } return myHeight; } function setscrollpos() { var objf=document.getElementById('loadscrollpos'); document.getElementById("leftnav").scrollTop = objf.offsetTop - getWinHeight()/2; } function addEvent(obj, evType, fn){ if (obj.addEventListener){ obj.addEventListener(evType, fn, true); return true; } else if (obj.attachEvent){ var r = obj.attachEvent("on"+evType, fn); return r; } else { return false; } } addEvent(window, 'load', setscrollpos); //--></script><div id="leftnav"><div class="innertube"> <img alt="Erlang logo" src="../../../../doc/erlang-logo.png"><br><small><a href="users_guide.html">User's Guide</a><br><a href="index.html">Reference Manual</a><br><a href="release_notes.html">Release Notes</a><br><a href="../pdf/tools-2.6.5.1.pdf">PDF</a><br><a href="../../../../doc/index.html">Top</a></small><p><strong>Tools</strong><br><strong>Reference Manual</strong><br><small>Version 2.6.5.1</small></p> <br><a href="javascript:openAllFlips()">Expand All</a><br><a href="javascript:closeAllFlips()">Contract All</a><p><small><strong>Table of Contents</strong></small></p> <ul class="flipMenu"> <li id="no" title="cover " expanded="false">cover<ul> <li><a href="cover.html"> Top of manual page </a></li> <li title="start-0"><a href="cover.html#start-0">start/0</a></li> <li title="start-1"><a href="cover.html#start-1">start/1</a></li> <li title="compile-1"><a href="cover.html#compile-1">compile/1</a></li> <li title="compile-2"><a href="cover.html#compile-2">compile/2</a></li> <li title="compile_module-1"><a href="cover.html#compile_module-1">compile_module/1</a></li> <li title="compile_module-2"><a href="cover.html#compile_module-2">compile_module/2</a></li> <li title="compile_directory-0"><a href="cover.html#compile_directory-0">compile_directory/0</a></li> <li title="compile_directory-1"><a href="cover.html#compile_directory-1">compile_directory/1</a></li> <li title="compile_directory-2"><a href="cover.html#compile_directory-2">compile_directory/2</a></li> <li title="compile_beam-1"><a href="cover.html#compile_beam-1">compile_beam/1</a></li> <li title="compile_beam_directory-0"><a href="cover.html#compile_beam_directory-0">compile_beam_directory/0</a></li> <li title="compile_beam_directory-1"><a href="cover.html#compile_beam_directory-1">compile_beam_directory/1</a></li> <li title="analyse-1"><a href="cover.html#analyse-1">analyse/1</a></li> <li title="analyse-2"><a href="cover.html#analyse-2">analyse/2</a></li> <li title="analyse-2"><a href="cover.html#analyse-2">analyse/2</a></li> <li title="analyse-3"><a href="cover.html#analyse-3">analyse/3</a></li> <li title="analyse_to_file-1"><a href="cover.html#analyse_to_file-1">analyse_to_file/1</a></li> <li title="analyse_to_file-2"><a href="cover.html#analyse_to_file-2">analyse_to_file/2</a></li> <li title="analyse_to_file-2"><a href="cover.html#analyse_to_file-2">analyse_to_file/2</a></li> <li title="analyse_to_file-3"><a href="cover.html#analyse_to_file-3">analyse_to_file/3</a></li> <li title="modules-0"><a href="cover.html#modules-0">modules/0</a></li> <li title="imported_modules-0"><a href="cover.html#imported_modules-0">imported_modules/0</a></li> <li title="imported-0"><a href="cover.html#imported-0">imported/0</a></li> <li title="which_nodes-0"><a href="cover.html#which_nodes-0">which_nodes/0</a></li> <li title="is_compiled-1"><a href="cover.html#is_compiled-1">is_compiled/1</a></li> <li title="reset-1"><a href="cover.html#reset-1">reset/1</a></li> <li title="reset-0"><a href="cover.html#reset-0">reset/0</a></li> <li title="export-1"><a href="cover.html#export-1">export/1</a></li> <li title="export-2"><a href="cover.html#export-2">export/2</a></li> <li title="import-1"><a href="cover.html#import-1">import/1</a></li> <li title="stop-0"><a href="cover.html#stop-0">stop/0</a></li> <li title="stop-1"><a href="cover.html#stop-1">stop/1</a></li> </ul> </li> <li id="no" title="cprof " expanded="false">cprof<ul> <li><a href="cprof.html"> Top of manual page </a></li> <li title="analyse-0"><a href="cprof.html#analyse-0">analyse/0</a></li> <li title="analyse-1"><a href="cprof.html#analyse-1">analyse/1</a></li> <li title="analyse-1"><a href="cprof.html#analyse-1">analyse/1</a></li> <li title="analyse-2"><a href="cprof.html#analyse-2">analyse/2</a></li> <li title="pause-0"><a href="cprof.html#pause-0">pause/0</a></li> <li title="pause-1"><a href="cprof.html#pause-1">pause/1</a></li> <li title="pause-2"><a href="cprof.html#pause-2">pause/2</a></li> <li title="pause-3"><a href="cprof.html#pause-3">pause/3</a></li> <li title="restart-0"><a href="cprof.html#restart-0">restart/0</a></li> <li title="restart-1"><a href="cprof.html#restart-1">restart/1</a></li> <li title="restart-2"><a href="cprof.html#restart-2">restart/2</a></li> <li title="restart-3"><a href="cprof.html#restart-3">restart/3</a></li> <li title="start-0"><a href="cprof.html#start-0">start/0</a></li> <li title="start-1"><a href="cprof.html#start-1">start/1</a></li> <li title="start-2"><a href="cprof.html#start-2">start/2</a></li> <li title="start-3"><a href="cprof.html#start-3">start/3</a></li> <li title="stop-0"><a href="cprof.html#stop-0">stop/0</a></li> <li title="stop-1"><a href="cprof.html#stop-1">stop/1</a></li> <li title="stop-2"><a href="cprof.html#stop-2">stop/2</a></li> <li title="stop-3"><a href="cprof.html#stop-3">stop/3</a></li> </ul> </li> <li id="no" title="eprof " expanded="false">eprof<ul> <li><a href="eprof.html"> Top of manual page </a></li> <li title="start-0"><a href="eprof.html#start-0">start/0</a></li> <li title="start_profiling-1"><a href="eprof.html#start_profiling-1">start_profiling/1</a></li> <li title="profile-1"><a href="eprof.html#profile-1">profile/1</a></li> <li title="stop_profiling-0"><a href="eprof.html#stop_profiling-0">stop_profiling/0</a></li> <li title="profile-2"><a href="eprof.html#profile-2">profile/2</a></li> <li title="profile-4"><a href="eprof.html#profile-4">profile/4</a></li> <li title="analyse-0"><a href="eprof.html#analyse-0">analyse/0</a></li> <li title="total_analyse-0"><a href="eprof.html#total_analyse-0">total_analyse/0</a></li> <li title="log-1"><a href="eprof.html#log-1">log/1</a></li> <li title="stop-0"><a href="eprof.html#stop-0">stop/0</a></li> </ul> </li> <li title="erlang.el"><a href="erlang.el.html">erlang.el</a></li> <li id="no" title="fprof " expanded="false">fprof<ul> <li><a href="fprof.html"> Top of manual page </a></li> <li title="start-0"><a href="fprof.html#start-0">start/0</a></li> <li title="stop-0"><a href="fprof.html#stop-0">stop/0</a></li> <li title="stop-1"><a href="fprof.html#stop-1">stop/1</a></li> <li title="apply-2"><a href="fprof.html#apply-2">apply/2</a></li> <li title="apply-3"><a href="fprof.html#apply-3">apply/3</a></li> <li title="apply-3"><a href="fprof.html#apply-3">apply/3</a></li> <li title="apply-4"><a href="fprof.html#apply-4">apply/4</a></li> <li title="trace-2"><a href="fprof.html#trace-2">trace/2</a></li> <li title="trace-2"><a href="fprof.html#trace-2">trace/2</a></li> <li title="trace-2"><a href="fprof.html#trace-2">trace/2</a></li> <li title="trace-1"><a href="fprof.html#trace-1">trace/1</a></li> <li title="trace-1"><a href="fprof.html#trace-1">trace/1</a></li> <li title="trace-1"><a href="fprof.html#trace-1">trace/1</a></li> <li title="trace-1"><a href="fprof.html#trace-1">trace/1</a></li> <li title="profile-0"><a href="fprof.html#profile-0">profile/0</a></li> <li title="profile-2"><a href="fprof.html#profile-2">profile/2</a></li> <li title="profile-1"><a href="fprof.html#profile-1">profile/1</a></li> <li title="profile-1"><a href="fprof.html#profile-1">profile/1</a></li> <li title="profile-1"><a href="fprof.html#profile-1">profile/1</a></li> <li title="analyse-0"><a href="fprof.html#analyse-0">analyse/0</a></li> <li title="analyse-2"><a href="fprof.html#analyse-2">analyse/2</a></li> <li title="analyse-1"><a href="fprof.html#analyse-1">analyse/1</a></li> <li title="analyse-1"><a href="fprof.html#analyse-1">analyse/1</a></li> <li title="analyse-1"><a href="fprof.html#analyse-1">analyse/1</a></li> </ul> </li> <li id="loadscrollpos" title="instrument " expanded="true">instrument<ul> <li><a href="instrument.html"> Top of manual page </a></li> <li title="allocator_descr-2"><a href="instrument.html#allocator_descr-2">allocator_descr/2</a></li> <li title="block_header_size-1"><a href="instrument.html#block_header_size-1">block_header_size/1</a></li> <li title="class_descr-2"><a href="instrument.html#class_descr-2">class_descr/2</a></li> <li title="descr-1"><a href="instrument.html#descr-1">descr/1</a></li> <li title="holes-1"><a href="instrument.html#holes-1">holes/1</a></li> <li title="mem_limits-1"><a href="instrument.html#mem_limits-1">mem_limits/1</a></li> <li title="memory_data-0"><a href="instrument.html#memory_data-0">memory_data/0</a></li> <li title="memory_status-1"><a href="instrument.html#memory_status-1">memory_status/1</a></li> <li title="read_memory_data-1"><a href="instrument.html#read_memory_data-1">read_memory_data/1</a></li> <li title="read_memory_status-1"><a href="instrument.html#read_memory_status-1">read_memory_status/1</a></li> <li title="sort-1"><a href="instrument.html#sort-1">sort/1</a></li> <li title="store_memory_data-1"><a href="instrument.html#store_memory_data-1">store_memory_data/1</a></li> <li title="store_memory_status-1"><a href="instrument.html#store_memory_status-1">store_memory_status/1</a></li> <li title="sum_blocks-1"><a href="instrument.html#sum_blocks-1">sum_blocks/1</a></li> <li title="type_descr-2"><a href="instrument.html#type_descr-2">type_descr/2</a></li> <li title="type_no_range-1"><a href="instrument.html#type_no_range-1">type_no_range/1</a></li> </ul> </li> <li id="no" title="lcnt " expanded="false">lcnt<ul> <li><a href="lcnt.html"> Top of manual page </a></li> <li title="start-0"><a href="lcnt.html#start-0">start/0</a></li> <li title="stop-0"><a href="lcnt.html#stop-0">stop/0</a></li> <li title="collect-0"><a href="lcnt.html#collect-0">collect/0</a></li> <li title="collect-1"><a href="lcnt.html#collect-1">collect/1</a></li> <li title="clear-0"><a href="lcnt.html#clear-0">clear/0</a></li> <li title="clear-1"><a href="lcnt.html#clear-1">clear/1</a></li> <li title="conflicts-0"><a href="lcnt.html#conflicts-0">conflicts/0</a></li> <li title="conflicts-1"><a href="lcnt.html#conflicts-1">conflicts/1</a></li> <li title="locations-0"><a href="lcnt.html#locations-0">locations/0</a></li> <li title="locations-1"><a href="lcnt.html#locations-1">locations/1</a></li> <li title="inspect-1"><a href="lcnt.html#inspect-1">inspect/1</a></li> <li title="inspect-2"><a href="lcnt.html#inspect-2">inspect/2</a></li> <li title="information-0"><a href="lcnt.html#information-0">information/0</a></li> <li title="swap_pid_keys-0"><a href="lcnt.html#swap_pid_keys-0">swap_pid_keys/0</a></li> <li title="load-1"><a href="lcnt.html#load-1">load/1</a></li> <li title="save-1"><a href="lcnt.html#save-1">save/1</a></li> <li title="apply-1"><a href="lcnt.html#apply-1">apply/1</a></li> <li title="apply-2"><a href="lcnt.html#apply-2">apply/2</a></li> <li title="apply-3"><a href="lcnt.html#apply-3">apply/3</a></li> <li title="pid-2"><a href="lcnt.html#pid-2">pid/2</a></li> <li title="pid-3"><a href="lcnt.html#pid-3">pid/3</a></li> <li title="port-1"><a href="lcnt.html#port-1">port/1</a></li> <li title="port-2"><a href="lcnt.html#port-2">port/2</a></li> <li title="rt_collect-0"><a href="lcnt.html#rt_collect-0">rt_collect/0</a></li> <li title="rt_collect-1"><a href="lcnt.html#rt_collect-1">rt_collect/1</a></li> <li title="rt_clear-0"><a href="lcnt.html#rt_clear-0">rt_clear/0</a></li> <li title="rt_clear-1"><a href="lcnt.html#rt_clear-1">rt_clear/1</a></li> <li title="rt_opt-1"><a href="lcnt.html#rt_opt-1">rt_opt/1</a></li> <li title="rt_opt-2"><a href="lcnt.html#rt_opt-2">rt_opt/2</a></li> </ul> </li> <li id="no" title="make " expanded="false">make<ul> <li><a href="make.html"> Top of manual page </a></li> <li title="all-0"><a href="make.html#all-0">all/0</a></li> <li title="all-1"><a href="make.html#all-1">all/1</a></li> <li title="files-1"><a href="make.html#files-1">files/1</a></li> <li title="files-2"><a href="make.html#files-2">files/2</a></li> </ul> </li> <li id="no" title="tags " expanded="false">tags<ul> <li><a href="tags.html"> Top of manual page </a></li> <li title="file-1"><a href="tags.html#file-1">file/1</a></li> <li title="files-1"><a href="tags.html#files-1">files/1</a></li> <li title="dir-1"><a href="tags.html#dir-1">dir/1</a></li> <li title="dirs-1"><a href="tags.html#dirs-1">dirs/1</a></li> <li title="subdir-1"><a href="tags.html#subdir-1">subdir/1</a></li> <li title="subdirs-1"><a href="tags.html#subdirs-1">subdirs/1</a></li> <li title="root-1"><a href="tags.html#root-1">root/1</a></li> </ul> </li> <li id="no" title="xref " expanded="false">xref<ul> <li><a href="xref.html"> Top of manual page </a></li> <li title="add_application-2"><a href="xref.html#add_application-2">add_application/2</a></li> <li title="add_directory-2"><a href="xref.html#add_directory-2">add_directory/2</a></li> <li title="add_module-2"><a href="xref.html#add_module-2">add_module/2</a></li> <li title="add_release-2"><a href="xref.html#add_release-2">add_release/2</a></li> <li title="analyze-2"><a href="xref.html#analyze-2">analyze/2</a></li> <li title="d-1"><a href="xref.html#d-1">d/1</a></li> <li title="forget-1"><a href="xref.html#forget-1">forget/1</a></li> <li title="forget-2"><a href="xref.html#forget-2">forget/2</a></li> <li title="format_error-1"><a href="xref.html#format_error-1">format_error/1</a></li> <li title="get_default-1"><a href="xref.html#get_default-1">get_default/1</a></li> <li title="get_default-2"><a href="xref.html#get_default-2">get_default/2</a></li> <li title="get_library_path-1"><a href="xref.html#get_library_path-1">get_library_path/1</a></li> <li title="info-1"><a href="xref.html#info-1">info/1</a></li> <li title="info-2"><a href="xref.html#info-2">info/2</a></li> <li title="info-3"><a href="xref.html#info-3">info/3</a></li> <li title="m-1"><a href="xref.html#m-1">m/1</a></li> <li title="m-1"><a href="xref.html#m-1">m/1</a></li> <li title="q-2"><a href="xref.html#q-2">q/2</a></li> <li title="remove_application-2"><a href="xref.html#remove_application-2">remove_application/2</a></li> <li title="remove_module-2"><a href="xref.html#remove_module-2">remove_module/2</a></li> <li title="remove_release-2"><a href="xref.html#remove_release-2">remove_release/2</a></li> <li title="replace_application-3"><a href="xref.html#replace_application-3">replace_application/3</a></li> <li title="replace_module-3"><a href="xref.html#replace_module-3">replace_module/3</a></li> <li title="set_default-3"><a href="xref.html#set_default-3">set_default/3</a></li> <li title="set_default-2"><a href="xref.html#set_default-2">set_default/2</a></li> <li title="set_library_path-2"><a href="xref.html#set_library_path-2">set_library_path/2</a></li> <li title="start-1"><a href="xref.html#start-1">start/1</a></li> <li title="start-2"><a href="xref.html#start-2">start/2</a></li> <li title="stop-1"><a href="xref.html#stop-1">stop/1</a></li> <li title="update-1"><a href="xref.html#update-1">update/1</a></li> <li title="variables-1"><a href="xref.html#variables-1">variables/1</a></li> </ul> </li> </ul> </div></div> <div id="content"> <div class="innertube"> <!-- refpage --><center><h1>instrument</h1></center> <h3>MODULE</h3> <div class="REFBODY">instrument</div> <h3>MODULE SUMMARY</h3> <div class="REFBODY">Analysis and Utility Functions for Instrumentation</div> <h3>DESCRIPTION</h3> <div class="REFBODY"><p> <p>The module <span class="code">instrument</span> contains support for studying the resource usage in an Erlang runtime system. Currently, only the allocation of memory can be studied.</p> <div class="note"> <div class="label">Note</div> <div class="content"><p> <p>Note that this whole module is experimental, and the representations used as well as the functionality is likely to change in the future.</p> <p>The <span class="code">instrument</span> module interface was slightly changed in Erlang/OTP R9C.</p> </p></div> </div> <p>To start an Erlang runtime system with instrumentation, use the <span class="code">+Mi*</span> set of command-line arguments to the <span class="code">erl</span> command (see the erts_alloc(3) and erl(1) man pages).</p> <p>The basic object of study in the case of memory allocation is a memory allocation map. A memory allocation map contains a list of descriptors for each allocated memory block. Currently, a descriptor is a 4-tuple</p> <div class="example"><pre> {TypeNo, Address, Size, PidDesc} </pre></div> <p>where <span class="code">TypeNo</span> is the memory block type number, <span class="code">Address</span> is its place in memory, and <span class="code">Size</span> is its size, in bytes. <span class="code">PidDesc</span> is either a tuple <span class="code">{X,Y,Z}</span> identifying the process which was executing when the block was allocated, or <span class="code">undefined</span> if no process was executing. The pid tuple <span class="code">{X,Y,Z}</span> can be transformed into a real pid by usage of the <span class="code">c:pid/3</span> function.</p> <p>Various details about memory allocation:</p> <p>Memory blocks are allocated both on the heap segment and on other memory segments. This can cause the instrumentation functionality to report very large holes. Currently the instrumentation functionality doesn't provide any support for distinguishing between holes between memory segments, and holes between allocated blocks inside memory segments. The current size of the process cannot be obtained from within Erlang, but can be seen with one of the system statistics tools, e.g., <span class="code">ps</span> or <span class="code">top</span>. The Solaris utility <span class="code">pmap</span> can be useful. It reports currently mapped memory segments. </p> <p>Overhead for instrumentation: When the emulator has been started with the <span class="bold_code"><a href="javascript:erlhref('../../../../doc/../','erts','erts_alloc.html#Mim');">"+Mim true"</a></span> flag, each block is preceded by a 24 bytes large header on a 32-bit machine and a 48 bytes large header on a 64-bit machine. When the emulator has been started with the <span class="bold_code"><a href="javascript:erlhref('../../../../doc/../','erts','erts_alloc.html#Mis');">"+Mis true"</a></span> flag, each block is preceded by an 8 bytes large header. These are the header sizes used by the Erlang 5.3/OTP R9C emulator. Other versions of the emulator may use other header sizes. The function <span class="bold_code"><a href="#block_header_size-1">block_header_size/1</a></span> can be used for retrieving the header size used for a specific memory allocation map. The time overhead for managing the instrumentation data is small.</p> <p>Sizes presented by the instrumentation functionality are (by the emulator) requested sizes, i.e. neither instrumentation headers nor headers used by allocators are included.</p> </p></div> <h3>EXPORTS</h3> <p><a name="allocator_descr-2"><span class="bold_code">allocator_descr(MemoryData, TypeNo) -> AllocDescr | invalid_type | "unknown"</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">MemoryData = {term(), AllocList}</span><br> </div> <div class="REFTYPES"> <span class="bold_code">AllocList = [Desc]</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Desc = {int(), int(), int(), PidDesc}</span><br> </div> <div class="REFTYPES"> <span class="bold_code">PidDesc = {int(), int(), int()} | undefined</span><br> </div> <div class="REFTYPES"> <span class="bold_code">TypeNo = int()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">AllocDescr = atom() | string()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns the allocator description of the allocator that manages memory blocks of type number <span class="code">TypeNo</span> used in <span class="code">MemoryData</span>. Valid <span class="code">TypeNo</span>s are in the range returned by <span class="bold_code"><a href="#type_no_range-1">type_no_range/1</a></span> on this specific memory allocation map. If <span class="code">TypeNo</span> is an invalid integer, <span class="code">invalid_type</span> is returned.</p> </p></div> <p><a name="block_header_size-1"><span class="bold_code">block_header_size(MemoryData) -> int()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">MemoryData = {term(), AllocList}</span><br> </div> <div class="REFTYPES"> <span class="bold_code">AllocList = [Desc]</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Desc = {int(), int(), int(), PidDesc}</span><br> </div> <div class="REFTYPES"> <span class="bold_code">PidDesc = {int(), int(), int()} | undefined</span><br> </div> </div> <div class="REFBODY"><p> <a name="block_header_size_1"></a> <p>Returns the memory block header size used by the emulator that generated the memory allocation map. The block header size may differ between different emulators.</p> </p></div> <p><a name="class_descr-2"><span class="bold_code">class_descr(MemoryData, TypeNo) -> ClassDescr | invalid_type | "unknown"</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">MemoryData = {term(), AllocList}</span><br> </div> <div class="REFTYPES"> <span class="bold_code">AllocList = [Desc]</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Desc = {int(), int(), int(), PidDesc}</span><br> </div> <div class="REFTYPES"> <span class="bold_code">PidDesc = {int(), int(), int()} | undefined</span><br> </div> <div class="REFTYPES"> <span class="bold_code">TypeNo = int()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">ClassDescr = atom() | string()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns the class description of the class that the type number <span class="code">TypeNo</span> used in <span class="code">MemoryData</span> belongs to. Valid <span class="code">TypeNo</span>s are in the range returned by <span class="bold_code"><a href="#type_no_range-1">type_no_range/1</a></span> on this specific memory allocation map. If <span class="code">TypeNo</span> is an invalid integer, <span class="code">invalid_type</span> is returned.</p> </p></div> <p><a name="descr-1"><span class="bold_code">descr(MemoryData) -> DescrMemoryData</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">MemoryData = {term(), AllocList}</span><br> </div> <div class="REFTYPES"> <span class="bold_code">AllocList = [Desc]</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Desc = {int(), int(), int(), PidDesc}</span><br> </div> <div class="REFTYPES"> <span class="bold_code">PidDesc = {int(), int(), int()} | undefined</span><br> </div> <div class="REFTYPES"> <span class="bold_code">DescrMemoryData = {term(), DescrAllocList}</span><br> </div> <div class="REFTYPES"> <span class="bold_code">DescrAllocList = [DescrDesc]</span><br> </div> <div class="REFTYPES"> <span class="bold_code">DescrDesc = {TypeDescr, int(), int(), DescrPidDesc}</span><br> </div> <div class="REFTYPES"> <span class="bold_code">TypeDescr = atom() | string()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">DescrPidDesc = pid() | undefined</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns a memory allocation map where the type numbers (first element of <span class="code">Desc</span>) have been replaced by type descriptions, and pid tuples (fourth element of <span class="code">Desc</span>) have been replaced by real pids.</p> </p></div> <p><a name="holes-1"><span class="bold_code">holes(MemoryData) -> ok</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">MemoryData = {term(), AllocList}</span><br> </div> <div class="REFTYPES"> <span class="bold_code">AllocList = [Desc]</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Desc = {int(), int(), int(), PidDesc}</span><br> </div> <div class="REFTYPES"> <span class="bold_code">PidDesc = {int(), int(), int()} | undefined</span><br> </div> </div> <div class="REFBODY"><p> <p>Prints out the size of each hole (i.e., the space between allocated blocks) on the terminal. <strong>NOTE:</strong> Really large holes are probably holes between memory segments. The memory allocation map has to be sorted (see <span class="bold_code"><a href="#sort-1">sort/1</a></span>).</p> </p></div> <p><a name="mem_limits-1"><span class="bold_code">mem_limits(MemoryData) -> {Low, High}</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">MemoryData = {term(), AllocList}</span><br> </div> <div class="REFTYPES"> <span class="bold_code">AllocList = [Desc]</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Desc = {int(), int(), int(), PidDesc}</span><br> </div> <div class="REFTYPES"> <span class="bold_code">PidDesc = {int(), int(), int()} | undefined</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Low = High = int()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns a tuple <span class="code">{Low, High}</span> indicating the lowest and highest address used. The memory allocation map has to be sorted (see <span class="bold_code"><a href="#sort-1">sort/1</a></span>).</p> </p></div> <p><a name="memory_data-0"><span class="bold_code">memory_data() -> MemoryData | false</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">MemoryData = {term(), AllocList}</span><br> </div> <div class="REFTYPES"> <span class="bold_code">AllocList = [Desc]</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Desc = {int(), int(), int(), PidDesc}</span><br> </div> <div class="REFTYPES"> <span class="bold_code">PidDesc = {int(), int(), int()} | undefined</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns <span class="code">MemoryData</span> (a the memory allocation map) if the emulator has been started with the "<span class="code">+Mim true</span>" command-line argument; otherwise, <span class="code">false</span>. <strong>NOTE:</strong><span class="code">memory_data/0</span> blocks execution of other processes while the data is collected. The time it takes to collect the data can be substantial.</p> </p></div> <p><a name="memory_status-1"><span class="bold_code">memory_status(StatusType) -> [StatusInfo] | false</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">StatusType = total | allocators | classes | types</span><br> </div> <div class="REFTYPES"> <span class="bold_code">StatusInfo = {About, [Info]}</span><br> </div> <div class="REFTYPES"> <span class="bold_code">About = atom()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Info = {InfoName, Current, MaxSinceLast, MaxEver}</span><br> </div> <div class="REFTYPES"> <span class="bold_code">InfoName = sizes|blocks</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Current = int()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">MaxSinceLast = int()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">MaxEver = int()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns a list of <span class="code">StatusInfo</span> if the emulator has been started with the "<span class="code">+Mis true</span>" or "<span class="code">+Mim true</span>" command-line argument; otherwise, <span class="code">false</span>. </p> <p>See the <span class="bold_code"><a href="#read_memory_status-1">read_memory_status/1</a></span> function for a description of the <span class="code">StatusInfo</span> term.</p> </p></div> <p><a name="read_memory_data-1"><span class="bold_code">read_memory_data(File) -> MemoryData | {error, Reason}</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">File = string()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">MemoryData = {term(), AllocList}</span><br> </div> <div class="REFTYPES"> <span class="bold_code">AllocList = [Desc]</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Desc = {int(), int(), int(), PidDesc}</span><br> </div> <div class="REFTYPES"> <span class="bold_code">PidDesc = {int(), int(), int()} | undefined</span><br> </div> </div> <div class="REFBODY"><p> <a name="read_memory_data_1"></a> <p>Reads a memory allocation map from the file <span class="code">File</span> and returns it. The file is assumed to have been created by <span class="code">store_memory_data/1</span>. The error codes are the same as for <span class="code">file:consult/1</span>.</p> </p></div> <p><a name="read_memory_status-1"><span class="bold_code">read_memory_status(File) -> MemoryStatus | {error, Reason}</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">File = string()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">MemoryStatus = [{StatusType, [StatusInfo]}]</span><br> </div> <div class="REFTYPES"> <span class="bold_code">StatusType = total | allocators | classes | types</span><br> </div> <div class="REFTYPES"> <span class="bold_code">StatusInfo = {About, [Info]}</span><br> </div> <div class="REFTYPES"> <span class="bold_code">About = atom()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Info = {InfoName, Current, MaxSinceLast, MaxEver}</span><br> </div> <div class="REFTYPES"> <span class="bold_code">InfoName = sizes|blocks</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Current = int()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">MaxSinceLast = int()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">MaxEver = int()</span><br> </div> </div> <div class="REFBODY"><p> <a name="read_memory_status_1"></a> <p>Reads memory allocation status from the file <span class="code">File</span> and returns it. The file is assumed to have been created by <span class="code">store_memory_status/1</span>. The error codes are the same as for <span class="code">file:consult/1</span>.</p> <p>When <span class="code">StatusType</span> is <span class="code">allocators</span>, <span class="code">About</span> is the allocator that the information is about. When <span class="code">StatusType</span> is <span class="code">types</span>, <span class="code">About</span> is the memory block type that the information is about. Memory block types are not described other than by their name and may vary between emulators. When <span class="code">StatusType</span> is <span class="code">classes</span>, <span class="code">About</span> is the memory block type class that information is presented about. Memory block types are classified after their use. Currently the following classes exist:</p> <dl> <dt><strong><span class="code">process_data</span></strong></dt> <dd>Erlang process specific data.</dd> <dt><strong><span class="code">binary_data</span></strong></dt> <dd>Erlang binaries.</dd> <dt><strong><span class="code">atom_data</span></strong></dt> <dd>Erlang atoms.</dd> <dt><strong><span class="code">code_data</span></strong></dt> <dd>Erlang code.</dd> <dt><strong><span class="code">system_data</span></strong></dt> <dd>Other data used by the system</dd> </dl> <p>When <span class="code">InfoName</span> is <span class="code">sizes</span>, <span class="code">Current</span>, <span class="code">MaxSinceLast</span>, and <span class="code">MaxEver</span> are, respectively, current size, maximum size since last call to <span class="code">store_memory_status/1</span> or <span class="code">memory_status/1</span> with the specific <span class="code">StatusType</span>, and maximum size since the emulator was started. When <span class="code">InfoName</span> is <span class="code">blocks</span>, <span class="code">Current</span>, <span class="code">MaxSinceLast</span>, and <span class="code">MaxEver</span> are, respectively, current number of blocks, maximum number of blocks since last call to <span class="code">store_memory_status/1</span> or <span class="code">memory_status/1</span> with the specific <span class="code">StatusType</span>, and maximum number of blocks since the emulator was started. </p> <p><strong>NOTE:</strong>A memory block is accounted for at "the first level" allocator. E.g. <span class="code">fix_alloc</span> allocates its memory pools via <span class="code">ll_alloc</span>. When a <span class="code">fix_alloc</span> block is allocated, neither the block nor the pool in which it resides are accounted for as memory allocated via <span class="code">ll_alloc</span> even though it is.</p> </p></div> <p><a name="sort-1"><span class="bold_code">sort(MemoryData) -> MemoryData</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">MemoryData = {term(), AllocList}</span><br> </div> <div class="REFTYPES"> <span class="bold_code">AllocList = [Desc]</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Desc = {int(), int(), int(), PidDesc}</span><br> </div> <div class="REFTYPES"> <span class="bold_code">PidDesc = {int(), int(), int()} | undefined</span><br> </div> </div> <div class="REFBODY"><p> <a name="sort_1"></a> <p>Sorts a memory allocation map so that the addresses are in ascending order.</p> </p></div> <p><a name="store_memory_data-1"><span class="bold_code">store_memory_data(File) -> true|false</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">File = string()</span><br> </div> </div> <div class="REFBODY"><p> <p>Stores the current memory allocation map on the file <span class="code">File</span>. Returns <span class="code">true</span> if the emulator has been started with the "<span class="code">+Mim true</span>" command-line argument, and the map was successfuly stored; otherwise, <span class="code">false</span>. The contents of the file can later be read using <span class="bold_code"><a href="#read_memory_data-1">read_memory_data/1</a></span>. <strong>NOTE:</strong><span class="code">store_memory_data/0</span> blocks execution of other processes while the data is collected. The time it takes to collect the data can be substantial.</p> </p></div> <p><a name="store_memory_status-1"><span class="bold_code">store_memory_status(File) -> true|false</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">File = string()</span><br> </div> </div> <div class="REFBODY"><p> <p>Stores the current memory status on the file <span class="code">File</span>. Returns <span class="code">true</span> if the emulator has been started with the "<span class="code">+Mis true</span>", or "<span class="code">+Mim true</span>" command-line arguments, and the data was successfuly stored; otherwise, <span class="code">false</span>. The contents of the file can later be read using <span class="bold_code"><a href="#read_memory_status-1">read_memory_status/1</a></span>.</p> </p></div> <p><a name="sum_blocks-1"><span class="bold_code">sum_blocks(MemoryData) -> int()</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">MemoryData = {term(), AllocList}</span><br> </div> <div class="REFTYPES"> <span class="bold_code">AllocList = [Desc]</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Desc = {int(), int(), int(), PidDesc}</span><br> </div> <div class="REFTYPES"> <span class="bold_code">PidDesc = {int(), int(), int()} | undefined</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns the total size of the memory blocks in the list.</p> </p></div> <p><a name="type_descr-2"><span class="bold_code">type_descr(MemoryData, TypeNo) -> TypeDescr | invalid_type</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">MemoryData = {term(), AllocList}</span><br> </div> <div class="REFTYPES"> <span class="bold_code">AllocList = [Desc]</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Desc = {int(), int(), int(), PidDesc}</span><br> </div> <div class="REFTYPES"> <span class="bold_code">PidDesc = {int(), int(), int()} | undefined</span><br> </div> <div class="REFTYPES"> <span class="bold_code">TypeNo = int()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">TypeDescr = atom() | string()</span><br> </div> </div> <div class="REFBODY"><p> <p>Returns the type description of a type number used in <span class="code">MemoryData</span>. Valid <span class="code">TypeNo</span>s are in the range returned by <span class="bold_code"><a href="#type_no_range-1">type_no_range/1</a></span> on this specific memory allocation map. If <span class="code">TypeNo</span> is an invalid integer, <span class="code">invalid_type</span> is returned.</p> </p></div> <p><a name="type_no_range-1"><span class="bold_code">type_no_range(MemoryData) -> {Min, Max}</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">MemoryData = {term(), AllocList}</span><br> </div> <div class="REFTYPES"> <span class="bold_code">AllocList = [Desc]</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Desc = {int(), int(), int(), PidDesc}</span><br> </div> <div class="REFTYPES"> <span class="bold_code">PidDesc = {int(), int(), int()} | undefined</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Min = int()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Max = int()</span><br> </div> </div> <div class="REFBODY"><p> <a name="type_no_range_1"></a> <p>Returns the memory block type number range used in <span class="code">MemoryData</span>. When the memory allocation map was generated by an Erlang 5.3/OTP R9C or newer emulator, all integers <span class="code">T</span> that satisfy <span class="code">Min</span> <= <span class="code">T</span> <= <span class="code">Max</span> are valid type numbers. When the memory allocation map was generated by a pre Erlang 5.3/OTP R9C emulator, all integers in the range are <strong>not</strong> valid type numbers.</p> </p></div> <h3><a name="id2283574">See Also</a></h3> <div class="REFBODY"> <p><span class="bold_code"><a href="javascript:erlhref('../../../../doc/../','erts','erts_alloc.html');">erts_alloc(3)</a></span>, <span class="bold_code"><a href="javascript:erlhref('../../../../doc/../','erts','erl.html');">erl(1)</a></span></p> </div> </div> <div class="footer"> <hr> <p>Copyright © 1997-2010 Ericsson AB. All Rights Reserved.</p> </div> </div> </div></body> </html>