Amount of heap memory reserved by a procces

  • Thread starter jose luis fernandez diaz
  • Start date
J

jose luis fernandez diaz

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.
 
J

John Harrison

jose luis fernandez diaz said:
Hi,

The program below gets 1 byte of heap memory:

To be specific, one byte of useable heap memory. It might actually reserve
more.
int main(void)
{
char *ptr = new char;
}

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

No. Not in standard C, (or C++ either).
Thanks,
Jose Luis.

john
 
M

Michael Groys

John said:
To be specific, one byte of useable heap memory. It might actually reserve
more.



process ?

No. Not in standard C, (or C++ either).

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top