From: "Markus Rechberger" <mrechberger@gmail.com>
To: Dan Gary <funkychunkymunky@gmail.com>
Cc: linux-c-programming@vger.kernel.org
Subject: Re: max heap usage of a Linux process
Date: Mon, 13 Nov 2006 16:59:22 +0100 [thread overview]
Message-ID: <d9def9db0611130759g549bc449i76c2b5e9bff09b3f@mail.gmail.com> (raw)
In-Reply-To: <1450f66c0611130739k5391a9adu26f9698f22df4c85@mail.gmail.com>
Hi,
On 11/13/06, Dan Gary <funkychunkymunky@gmail.com> wrote:
> unless parent is asking about malloc'd space, then mallinfo() or
> malloc_stats() might be what they're looking for, memory profiling the
> manual way, gotta love it
>
interesting didn't know that..
though now I have a question about it ..
#include <malloc.h>
#include <stdio.h>
#include <stdlib.h>
int main(){
char *foo;
printf("total free space: %d\n",mallinfo().fordblks);
foo=malloc(500000);
if(foo){
printf("successfully allocated!\n");
} else {
printf("error allocating!\n");
}
printf("arena: %d\n",mallinfo().arena);
printf("ordblks: %d\n",mallinfo().ordblks);
printf("max total allocated space: %d\n",mallinfo().usmblks);
printf("total allocated space: %d\n",mallinfo().uordblks);
printf("total free space: %d\n",mallinfo().fordblks);
return 0;
}
outputs:
total free space: 0
successfully allocated!
arena: 0
ordblks: 1
max total allocated space: 0
total allocated space: 0
total free space: 0
If I allocate 50000bytes then it outputs:
total free space: 0
successfully allocated!
arena: 184320
ordblks: 1
max total allocated space: 0
total allocated space: 50008
total free space: 134312
does anyone have an explanation for that?
Markus
next prev parent reply other threads:[~2006-11-13 15:59 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-11-13 13:31 max heap usage of a Linux process Prasanta Sadhukhan
2006-11-13 14:09 ` Markus Rechberger
2006-11-13 15:39 ` Dan Gary
2006-11-13 15:59 ` Markus Rechberger [this message]
2006-11-13 16:12 ` Christ, Bryan
2006-11-14 6:26 ` Prasanta Sadhukhan
2006-11-14 10:57 ` Glynn Clements
2006-11-14 11:30 ` Prasanta Sadhukhan
2006-11-14 14:36 ` Glynn Clements
2006-11-14 11:39 ` Al Boldi
2006-11-14 15:19 ` Christ, Bryan
2006-11-13 15:30 ` Christ, Bryan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d9def9db0611130759g549bc449i76c2b5e9bff09b3f@mail.gmail.com \
--to=mrechberger@gmail.com \
--cc=funkychunkymunky@gmail.com \
--cc=linux-c-programming@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).