.\" the source, must acknowledge the copyright and authors of this work.
.\" %%%LICENSE_END
.\"
-.TH MALLOC_INFO 3 2015-07-23 "GNU" "Linux Programmer's Manual"
+.TH MALLOC_INFO 3 2019-03-06 "GNU" "Linux Programmer's Manual"
.SH NAME
malloc_info \- export malloc state to a stream
.SH SYNOPSIS
After the blocks of memory have been allocated,
.BR malloc_info ()
shows the state of two allocation arenas.
+.PP
.in +4
-.nf
-
+.EX
.RB "$ " "getconf GNU_LIBC_VERSION"
glibc 2.13
.RB "$ " "./a.out 1 10000 100"
<aspace type="total" size="2113536"/>
<aspace type="mprotect" size="2113536"/>
</malloc>
-.fi
+.EE
.in
.SS Program source
-.nf
-
+.EX
#include <unistd.h>
#include <stdlib.h>
#include <pthread.h>
static size_t blockSize;
static int numThreads, numBlocks;
-#define errExit(msg) do { perror(msg); exit(EXIT_FAILURE); \\
+#define errExit(msg) do { perror(msg); exit(EXIT_FAILURE); \e
} while (0)
static void *
if (argc < 4) {
fprintf(stderr,
- "%s num\-threads num\-blocks block\-size [sleep\-time]\\n",
+ "%s num\-threads num\-blocks block\-size [sleep\-time]\en",
argv[0]);
exit(EXIT_FAILURE);
}
if (thr == NULL)
errExit("calloc");
- printf("============ Before allocating blocks ============\\n");
+ printf("============ Before allocating blocks ============\en");
malloc_info(0, stdout);
/* Create threads that allocate different amounts of memory */
sleep(2); /* Give all threads a chance to
complete allocations */
- printf("\\n============ After allocating blocks ============\\n");
+ printf("\en============ After allocating blocks ============\en");
malloc_info(0, stdout);
exit(EXIT_SUCCESS);
}
-.fi
+.EE
.SH SEE ALSO
.BR mallinfo (3),
.BR malloc (3),