Alex Rivera | Logout

Determine size of dynamically allocated memory in C

Asked 2009-08-15T11:21:09.077
96

Is there a way in C to find out the size of dynamically allocated memory?

For example, after

char* p = malloc (100);

Is there a way to find out the size of memory associated with p?

Edit
Report

1 Answer

1

If you use malloc then you can not get the size.

In the other hand, if you use OS API to dynamically allocate memory, like Windows heap functions, then it's possible to do that.

answered 2009-08-15T11:36:53.600

Your Answer