Re: How to get total heap size of a process
- From: CBFalconer <cbfalconer@xxxxxxxxx>
- Date: Thu, 08 Jun 2006 02:41:17 -0400
Andrew Poelstra wrote:
.... snip ...
int main(void)
{
/* puzzle. Why will this code break if we make a x a size_t ? */
unsigned long x = 0;
while(malloc(1))
x++;
printf("You have %lu bytes available\n", x);
return 0;
}
Because printf can't handle a size_t?
Exactly. You should cast x to (unsigned long). This will work on
C90 systems, provided only that an unsigned long can express a
size_t. For C99 you can use %z (I think).
--
"Our enemies are innovative and resourceful, and so are we.
They never stop thinking about new ways to harm our country
and our people, and neither do we." -- G. W. Bush.
"The people can always be brought to the bidding of the
leaders. All you have to do is tell them they are being
attacked and denounce the pacifists for lack of patriotism
and exposing the country to danger. It works the same way
in any country." --Hermann Goering.
.
- References:
- How to get total heap size of a process
- From: ganesh.kundapur@xxxxxxxxx
- Re: How to get total heap size of a process
- From: Malcolm
- Re: How to get total heap size of a process
- From: Andrew Poelstra
- How to get total heap size of a process
- Prev by Date: Any references on pattern matching?
- Next by Date: Re: NEED HELP WITH A PROGRAM....ANYONE PLEASE HELP!
- Previous by thread: Re: How to get total heap size of a process
- Next by thread: nested conditional operator
- Index(es):
Relevant Pages
|