W
wojtek.fedorko
Hi,
Is there a way of knowing how much memory a call to free() actually
freed?
thanks,
Wojtek
Is there a way of knowing how much memory a call to free() actually
freed?
thanks,
Wojtek
Hi,
Is there a way of knowing how much memory a call to free() actually
freed?
[email protected] said:Hi,
Is there a way of knowing how much memory a call to free() actually
freed?
thanks,
How widespread is this undocumented function? To be honest, it sounds likepete m said:Not in general. However, if your system supports the undocumented
function mstats(), you can call it before and after free and take the
difference. (You may have to use debug malloc, which is horrible.)
from malloc.h:
struct mstats {
size_t bytes_total;
size_t chunks_used;
size_t bytes_used;
size_t chunks_free;
size_t bytes_free;
};
extern struct mstats mstats(void);
How widespread is this undocumented function? To be honest, it sounds like
a practical joke.
Not in general. However, if your system supports the undocumented
function mstats(), you can call it before and after free and take the
difference. (You may have to use debug malloc, which is horrible.)
from malloc.h:
Hi,
Is there a way of knowing how much memory a call to free() actually
freed?
thanks,
Wojtek
Your reply, in addition to being off-topic, will be totally useless to
the OP if his (unnamed) platform is not the same as your (unnamed)
platform.
This group discusses the standard C language. It does NOT have any
undocumented functions.
In fact, all of the answers posted so far are wrong in one way or
another.
My answer was off topic; yours gives the wrong value.
Free does not free the same amount of memory as the size of the malloc
request. At the very least, free must release a multiple of 4 or 8
(or possibly 16) bytes, and there is also overhead from the data
structure used by the free list. And presumably one reason someone
might ask this question is to find out what the system overhead
actually is.
If you want to talk about non-standard, platform specific extensions,
post on groups for the platform.
pete m said:Free does not free the same amount of memory as the size of the malloc
request. At the very least, free must release a multiple of 4 or 8
(or possibly 16) bytes
and there is also overhead from the data structure used by the free list.
Apparently several platforms have the same extension. Do you suggest
newsgroups for all combinations of platforms?
Two possibilities:
1) the different platforms have different extensions with the same
name. In this case, its /vital/ to post in the right platform
specific group.
2) the different platforms have an identical extension. In this case
it doesn't matter which platform-specific group one posts to.
Either way, one assumes that the OP (and you) can 'engage your brain'
before posting?
How widespread is this undocumented function? To be honest, it sounds
like a practical joke.
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.