⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mprof.1

📁 早期freebsd实现
💻 1
字号:
.TH mprof 1.SH NAMEmprof \- display dynamic memory allocation data.SH SYNTAX.B mprof[ options ] [ a.out [ mprof.data ] ].nf.PP.B void set_mprof_autosave(count).B int count;.PP.B void mprof_stop().PP.B void mprof_restart(filename).B char *filename;.fi.SH DESCRIPTIONThe.B mprofcommand produces four tables that summarize the memory allocationbehavior of C programs, similar in style to the.B gprofcommand.  The arguments to  .B mprofare the executable image.I (a.outdefault)and the profile data file.I (mprof.datadefault).  The.I mprof.datafile is generated by linking a special version .I mallocinto the executing image. This new version, found in the library.I libc_mp.amust be linked in at the end of the command that creates theexecutable image.  For example:.sp.nf	cc -g -o test main.o sub1.o sub2.o libc_mp.a.fi.sp.PPUsers' programs can contain additional calls to customize the userinterface to.B mprof.The function.I set_mprof_autosaveallows users to save the profile data periodically.  The.I countparameter specifies to save after that number of allocations.A value of 10,000 or 100,000 is typical for the.I countparameter for long running programs.  A value of 0 (the default)causes the the profile data to be written only when the program exits.The function.I mprof_stopcauses memory profiling to be discontinued and the profile data to bewritten to the output file.The function.I mprof_restartrestarts profiling.  The.I filenameparameter to.I mprof_restartspecifies the name of the file to write the profile data to..PPThe output of.B mprofconsists of four tables, the fields of which are described in detailbelow.  The first table breaks down the memory allocation of theprogram by the number of bytes requested.  For each byte size thenumber of allocations and frees is listed along with the programstructure types that correspond to that byte size..PPThe second table lists partial call chains over which memory wasallocated and never freed (call chains resulting in memory leaks).The table shows how much memory was allocated by each chain and howmuch each chain contributed to the total memory leakage..PPThe third table lists the functions in whichallocation occurred directly (i.e., called.I malloc),indicates how much memory was allocated, shows how much of that wasnot later freed, breaks down allocation roughly by size, and shows howmany times each function was called..PPThe fourth table contains thesubgraph of the program's dynamic call graph in which allocationoccurred.  This table allows programmers to identify what functionswere indirectly responsible for memory allocation..PPThe following options are available:.TP.B \-verboseEvery bin in which memory was allocated is printed; the call chain forevery memory leak is shown..TP.B \-normalOnly bins that contributed a reasonable fraction to the totalallocation are printed; call chains for leaks contributing more than0.5% to the total are shown.  This is the default verbosity setting..TP.B \-terseOnly bins that contributed a significant fraction to the totalallocation are printed.  Call chains contributing more than 1% to thetotal leakage are shown..TP.B \-leaktablePrint out the memory leak table without printing out call site offsets.This is the default..TP.B \-noleaktableDo not print out the memory leak table..TP.B \-offsetsPrint out the memory leak table and distinguish different call siteswithin a function by indicating the offset in the function as part ofthe path.  This is useful to identify a particular call site in afunction with many call sites that allocate memory..SH FIELDS IN THE OUTPUT.LPOften in the tables, percentages are presented in two column fields.In such a field, a blankindicates 0%, a dot indicates less than 1%, and two starsindicate 100%..LPWhen data is broken down by size categories, the categories mean thefollowing:.nf	s = small      		x <= 32 bytes	m = medium     		32 < x <= 256 bytes	l = large      		256 < x <= 2048 bytes	x = extra large		x > 2048 bytes.fi.LPwhere x is the exact size of the object being allocated by a call tomalloc.  When data is broken into categories, percentages are alwaysgiven in a two column format.Throughout this document, we refer to such a listing asa ``breakdown''..SH "TABLE 1: ALLOCATION BINS".LPThe memory allocation is broken down by the sizes of objects requestedand freed..IP size 14The size in bytes of the object allocated or freed..IP allocs 14The number of calls to malloc requesting allocation of this size..IP "bytes (%)" 14The total number of bytes allocated to objects of this size.  Thepercent indicates the percent of the total bytes allocated..IP frees 14The number of times objects of this size were freed..IP "kept (%)" 14The number of bytes of objects of this size that were never freed.The percent indicates what fraction of unfreed bytes were allocated toobjects of this size.  .IP types 14A list of the program names of structure types or typedefs that defineobjects of this size..SH "TABLE 2: MEMORY LEAKS".LPThe memory leak table lists the partial call chains which allocatedmemory that was never freed.  At most five functions in the call chain arelisted..IP "kept bytes (%)" 14The number of bytes allocated on this partial call chainand not subsequently freed.The table is sorted by decreasing values in this field.The percent indicates the percent of total bytes not freed..IP allocs 14The number of allocations that occurred on this partial call chain..IP "bytes (%)" 14The number of bytes allocated on this partial call chain.  The percentindicates the percent of the total bytes allocated and never freed.  .IP frees 14The number of frees that occurred on this partial call chain.  If noobjects were freed this and the following field are ommitted..IP "bytes (%)" 14The number of bytes freed on this partial call chain.  This field isomitted if no bytes were freed..IP path 14The partial call chain.  Call chains starting with "..." indicate thatmore callers were present, but were ommitted from the listing.  Callchains consist of function names (and possible call site offsets)separated by ">".  Call site offsets are indicated by a +nfollowing the function name, where n is the distance in bytes of thecall site from the start of the function.  Call site offsets areprinted using the -offset option..SH "TABLE 3: DIRECT ALLOCATION".LPThe <TOTAL> row of the direct allocation listing contains a summary ofall the functions where such a summary makes sense..IP "% mem" 14Percentage of the total memory allocated that was allocated by thisfunction.  .IP bytes 14The total number of bytes allocated by this function..IP "% mem(size)" 14Size breakdown of the memory allocated by this function as apercentage of the total memory allocated by the program.  For example,if the values for function MAIN are s=5, m=20, l=4, x=0, then directcalls to MALLOC from MAIN account for 5+20+4+0 = 29% of the totalmemory allocated by the program.  Moreover, 20% of the total memoryallocated by the program was of medium sized objects (between 33 and256 bytes) by the function MAIN.  The <TOTAL> row represents thebreakdown by size of all the memory allocated by the program..IP "bytes kept" 14The number of bytes allocated by this function that were never freed(by calls to FREE)..IP "% all kept" 14The size breakdown of objects never freed by this function as apercentage of all objects never freed.  For example, if <% all kept>values for function MAIN are s=2, m=10, l=<blank>, x=<blank>, then 10%of the total bytes not freed were allocated by MAIN and were allocatedin medium-sized chunks.  The <TOTAL> row represents the size breakdownof all the memory allocated but never freed..IP "calls" 14The number of times this function was called to allocate an object..IP "name" 14The name of the function..SH "TABLE 4: ALLOCATION CALL GRAPH".LPA star (*) indicates that this field is omitted for ancestors ordescendents in the same cycle as the function..LPCycles are listed twice.The first appearance shows all the functionsthat are members of the cycle and the amount of memory allocatedlocally in each function, including the breakdown of the localallocation by size and the breakdown by size as a fraction of thetotal cycle.The second appearance shows what the callgraph would look like if all the functions in the cycle were mergedinto a single function..IP "index" 14A unique index used to aid searching for functions in the call graph listing..IP "self + desc" 14The percent of the total allocated memory that was allocated by thisfunction and its descendents.  .IP "self (%)" 14The number of bytes allocated by the function itself.  The percentageindicates the fraction of the bytes allocated by the function and itsdescendents that were allocated in the function itself..IP "size-func" 14The size breakdown of objects allocated in the function itself (notincluding its descendents.).IP "called" 14The number of times this function was called while allocating memory..IP "recur" 14The number of recursive function calls while allocating memory..IP "name" 14The function name including possible cycle membership and index..SH "ANCESTOR LISTINGS".lpIf the word ``all'' appears in the <self + desc> column, then this rowrepresents a summary of all the ancestors and presents the totalnumber of bytes requested by all ancestors in the <bytes> column, andthe breakdown of these bytes by size in the <self-ances> breakdowncolumns.  If there is only one ancestor, then this summary is omitted..IP "*self (%)" 14The number of bytes allocated by the function and its descendents thatwere allocated on behalf of this parent.  The percentage indicateswhat fraction of the total bytes allocated by the function and itsdescendents were allocated on behalf of this parent..IP "*size-ances" 14The size breakdown of the bytes allocated by the function and itsdescendents on behalf of this parent..IP "*frac-ances" 14The size breakdown of the objects allocated in the function and itsdescendents on behalf of this parent as a percentage of all objectsallocated by the function and its descendents.  For example if parentP1 of function F has <frac-ances> values s=<blank>, m=<blank>, l=30,x=<blank>, then 30% of all objects allocated by F and its descendentsare of large objects allocated on behalf of parent P1..IP "called" 14The number of times this parent called this function whilerequesting memory..IP "*total" 14The number of calls this parent made requesting memory from any function..IP "ancestors" 14The name of the parent including possible cycle membership and index..SH "DESCENDENT LISTINGS".LPIf the word ``all'' appears in the <self + desc> column, then this rowrepresents a summary of all the descendents and presents the totalnumber of bytes allocated by all descendents in the <bytes> column,and the breakdown of these bytes by size in the <self-desc> breakdowncolumns.  If there is only one descendent, then this summary isomitted..IP "*self (%)" 14The number of bytes allocated in this descendent that were allocatedat the request of the function.  The percentage indicates whatfraction of the total bytes allocated in descendents of the functionwere allocated in this descendent..IP "*size-ances" 14The size breakdown of the bytes allocated by this descendent on behalfof the function..IP "*frac-desc" 14The size breakdown of the objects allocated in this descendent onbehalf of the function as a percentage of all objects allocated by alldescendents on behalf of this function.  For example if descendent C1of function F has <frac-desc> values s=35, m=<blank>, l=<blank>, x=<blank>,then 35% of all objects allocated by children of F on its behalf wereallocated in child C1 and were small objects. .IP "called" 14The number of times the function called this descendent whilerequesting memory..IP "*total" 14The number of times this descendent was called during a memory request..IP "descendents" 14The name of the child including possible cycle membership and index..SH FILES.nfa.out         	contains symbol table information.mprof.data    	memory allocation call graph information.libc_mp.a	special version of malloc which profiles allocation.                (eventually to be put in /lib/local/mprof/libc_mp.a).fi.SH "SEE ALSO"cc(1), gprof(1).br.I A Memory Allocation Profiler for C.I and Lisp Programs,Benjamin Zorn and Paul Hilfinger, Summer 1988 USENIX Conference..SH AUTHORWritten by Benjamin Zorn, zorn@ernie.berkeley.edu, as part of Ph.D.research sponsored by the SPUR research project..SH BUGSThe code that determines the names and sizes of user types is poorlywritten and depends on the program being compiled with the -g option.In some cases (mostly very simple cases) the user type names arenot correctly determined..PPIf the user application calls.I vallocor.I memalignand later tries to free that memory,.B mprofwill cause a segmentation fault.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -