blob: 2cb52c92c9ba421b723d3d8df51dc1061566c205 [file]
<html lang="en">
<head>
<title>mallinfo - Untitled</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Untitled">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Stdlib.html#Stdlib" title="Stdlib">
<link rel="prev" href="malloc.html#malloc" title="malloc">
<link rel="next" href="_005f_005fmalloc_005flock.html#g_t_005f_005fmalloc_005flock" title="__malloc_lock">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family:serif; font-weight:normal; }
span.sansserif { font-family:sans-serif; font-weight:normal; }
--></style>
</head>
<body>
<div class="node">
<a name="mallinfo"></a>
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="_005f_005fmalloc_005flock.html#g_t_005f_005fmalloc_005flock">__malloc_lock</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="malloc.html#malloc">malloc</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="Stdlib.html#Stdlib">Stdlib</a>
<hr>
</div>
<h3 class="section">2.24 <code>mallinfo</code>, <code>malloc_stats</code>, <code>mallopt</code>&mdash;malloc support</h3>
<p><a name="index-mallinfo-49"></a><a name="index-malloc_005fstats-50"></a><a name="index-mallopt-51"></a><a name="index-g_t_005fmallinfo_005fr-52"></a><a name="index-g_t_005fmalloc_005fstats_005fr-53"></a><a name="index-g_t_005fmallopt_005fr-54"></a><strong>Synopsis</strong>
<pre class="example"> #include &lt;malloc.h&gt;
struct mallinfo mallinfo(void);
void malloc_stats(void);
int mallopt(int <var>parameter</var>, <var>value</var>);
struct mallinfo _mallinfo_r(void *<var>reent</var>);
void _malloc_stats_r(void *<var>reent</var>);
int _mallopt_r(void *<var>reent</var>, int <var>parameter</var>, <var>value</var>);
</pre>
<p><strong>Description</strong><br>
<code>mallinfo</code> returns a structure describing the current state of
memory allocation. The structure is defined in malloc.h. The
following fields are defined: <code>arena</code> is the total amount of space
in the heap; <code>ordblks</code> is the number of chunks which are not in use;
<code>uordblks</code> is the total amount of space allocated by <code>malloc</code>;
<code>fordblks</code> is the total amount of space not in use; <code>keepcost</code> is
the size of the top most memory block.
<p><code>malloc_stats</code> print some statistics about memory allocation on
standard error.
<p><code>mallopt</code> takes a parameter and a value. The parameters are defined
in malloc.h, and may be one of the following: <code>M_TRIM_THRESHOLD</code>
sets the maximum amount of unused space in the top most block before
releasing it back to the system in <code>free</code> (the space is released by
calling <code>_sbrk_r</code> with a negative argument); <code>M_TOP_PAD</code> is the
amount of padding to allocate whenever <code>_sbrk_r</code> is called to
allocate more space.
<p>The alternate functions <code>_mallinfo_r</code>, <code>_malloc_stats_r</code>, and
<code>_mallopt_r</code> are reentrant versions. The extra argument <var>reent</var>
is a pointer to a reentrancy structure.
<p><br>
<strong>Returns</strong><br>
<code>mallinfo</code> returns a mallinfo structure. The structure is defined
in malloc.h.
<p><code>malloc_stats</code> does not return a result.
<p><code>mallopt</code> returns zero if the parameter could not be set, or
non-zero if it could be set.
<p><br>
<strong>Portability</strong><br>
<code>mallinfo</code> and <code>mallopt</code> are provided by SVR4, but <code>mallopt</code>
takes different parameters on different systems. <code>malloc_stats</code> is
not portable.
<p><br>
</body></html>