c++ - Questions about MMGR -
i have been taking @ mmgr memory allocation checker , have few questions don't see anywhere else on internet.
1) there "reported size" , "actual size". understand "reported size" is, being size new receives, however, "actual size"? why there difference?
2) logging safe? see logging happens @ end of static deallocation of class, however, give false positive of memory leaks? 2a) sure, static deallocations happen last, right?
3) code thread safe? if not, how can become thread safe?
i'm afraid not have experience mmgr, can provide answer first question.
the reason memory debuggers mention reported (or requested) , actual allocation size has way memory allocators work. allocate requested size - reserve bit more. there various possible reasons:
alignment issues: don't think there allocator allocate e.g. 3 bytes on modern 32-bit (or more) system. value rounded at least next multiple of word-size or 4, depending on architecture.
management issues: allocators handle allocations sized powers of two. blocks of 4, 8, 16, 32, 64, 128, 256 etc bytes. rare in userspace allocators, common in kernel-space ones.
providence: allocators allocate bit more each time in anticipation of possible reallocation.
in case, reserved memory more amount requested, hence existence of 2 numbers.
Comments
Post a Comment