I tried to figure out how the malloc_info () function located in malloc.h works. I know that you must transfer FILE * to him and that no options have been implemented, but I don’t understand what he is actually reporting !? In addition, I wrote a test application that allocates a whole bunch of memory, and the values specified in the malloc_info () file do not change, unless I allocated 20,000 1 bytes.
Is there anyone who has experience with malloc_info () and can shed light on what aspects of memory it should measure?
It should be noted that I almost did not find anything in google about malloc_info (), just some fragmentary error reports.
Example output from malloc_info ():
<malloc version="1"> <heap nr="0"> <sizes> </sizes> <total type="fast" count="0" size="0"/> <total type="rest" count="0" size="0"/> <system type="current" size="135168"/> <system type="max" size="135168"/> <aspace type="total" size="135168"/> <aspace type="mprotect" size="135168"/> </heap> <total type="fast" count="0" size="0"/> <total type="rest" count="0" size="0"/> <system type="current" size="135168"/> <system type="max" size="135168"/> <aspace type="total" size="135168"/> <aspace type="mprotect" size="135168"/> </malloc>
EDIT:
As an additional explanation; my fallback position is the mallinfo () function, but I was hoping to use malloc_info (), because from what I can collect, it is intended to replace mallinfo (). I found that mallinfo () and malloc_info () do not work the same. In my tests, mallinfo () keeps track of all my distributions, and malloc_info () does not do this at all. I can only assume that malloc_info () is currently broken, or it is not intended to accomplish the same purpose as mallinfo ().
The article submitted by omnifarious has good reasons why mallinfo () should be deprecated:
it is completely unsuitable for 64-bit machines. The data types required by the SysV specification do not allow values greater than 2 ^ 31 bytes (all fields in the structure are ints). The second problem is that the data structure is really specific to the malloc SysV implementation used at that time.
However, I think that at this time malloc_info () is not ready to take this place.
FURTHER CHANGE: After a bit more digging, it seems that malloc_info () reports the arena size from mallinfo () in all places where 135168 appears (at least that matches). This seems much less useful and represents a very one-dimensional piece of information compared to what mallinfo () allows.
c ++ c gcc gnu
radman
source share