Thread View: comp.sys.next.programmer
1 messages
1 total messages
Started by Tom Horton
Mon, 27 Jul 1992 17:46
problem with mstats() under 2.1
Author: Tom Horton
Date: Mon, 27 Jul 1992 17:46
Date: Mon, 27 Jul 1992 17:46
49 lines
2197 bytes
2197 bytes
Hi. I'm writing some C code that will run on a couple of machines, and I'd
like to use the mstats() function to get a report on how much mamory has been
malloc'd. But it doesn't work like the man page says it should; in fact, it
doesn't seem to do anything. It prints nothing and always seems to return 1.
The man page says:
Mstats prints a summary of memory usage by malloc on stderr.
The efficiency value is calculated based on the rounded-off
block sizes, and is the ratio of the space available in the
blocks to the total amount of memory allocated by malloc.
The value returned is the total amount of memory allocated,
in bytes.
But this program prints the output that follows:
#include <stdlib.h>
#include <stdio.h>
int main (int argc, char *argv[])
{
char *buf;
size_t m_result;
if ( (buf = malloc(30)) == NULL ) {
fprintf(stderr, "error: malloc failed\n");
exit(1);
}
m_result = mstats();
printf("mstats returns: %ld\n", (long) m_result);
if ( (buf = malloc(1000)) == NULL ) {
fprintf(stderr, "error: malloc failed\n");
exit(1);
}
m_result = mstats();
printf("mstats returns: %ld\n", (long) m_result);
}
OUTPUT:
mstats returns: 1
mstats returns: 1
Any suggestions? I know about MallocDebug, but I'm not really writing a
NeXTstep application or using IB.
--
-------------------------------------------------------------------------
Dr. Thomas B. Horton, Assistant Professor
Dept. of Computer Science and Engineering, Florida Atlantic University
Boca Raton, FL 33431 USA Phone: 407/367-2674 FAX: 407/367-2800
Internet: tom@cse.fau.edu Bitnet: HortonT@fauvax
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads