Amount of heap memory reserved by a procces

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jose luis fernandez diaz

    Amount of heap memory reserved by a procces

    Hi,

    The program below gets 1 byte of heap memory:

    int main(void)
    {
    char *ptr = new char;
    }

    Is there a C system call that give the amount of memory reserved by a process ?

    Thanks,
    Jose Luis.
  • John Harrison

    #2
    Re: Amount of heap memory reserved by a procces


    "jose luis fernandez diaz" <jose_luis_fdez _diaz_news@yaho o.es> wrote in
    message news:c2f95fd0.0 402090045.53297 699@posting.goo gle.com...[color=blue]
    > Hi,
    >
    > The program below gets 1 byte of heap memory:
    >[/color]

    To be specific, one byte of useable heap memory. It might actually reserve
    more.
    [color=blue]
    > int main(void)
    > {
    > char *ptr = new char;
    > }
    >
    > Is there a C system call that give the amount of memory reserved by a[/color]
    process ?

    No. Not in standard C, (or C++ either).
    [color=blue]
    >
    > Thanks,
    > Jose Luis.[/color]

    john


    Comment

    • Michael Groys

      #3
      Re: Amount of heap memory reserved by a procces



      John Harrison wrote:[color=blue]
      > "jose luis fernandez diaz" <jose_luis_fdez _diaz_news@yaho o.es> wrote in
      > message news:c2f95fd0.0 402090045.53297 699@posting.goo gle.com...
      >[color=green]
      >>Hi,
      >>
      >>The program below gets 1 byte of heap memory:
      >>[/color]
      >
      >
      > To be specific, one byte of useable heap memory. It might actually reserve
      > more.
      >
      >[color=green]
      >>int main(void)
      >>{
      >> char *ptr = new char;
      >>}
      >>
      >>Is there a C system call that give the amount of memory reserved by a[/color]
      >
      > process ?
      >
      > No. Not in standard C, (or C++ either).
      >[/color]

      In VC there is function:
      size_t _msize(void *memblock)
      It returns size of allocated memory block.
      It works with malloc/calloc/realloc.
      Still it may return more then 1 in your example.
      I assume that it also works with new although no guarantee.
      [color=blue][color=green]
      >>Thanks,
      >>Jose Luis.[/color]
      >
      >
      > john
      >
      >[/color]

      Comment

      Working...