c - memory request Linux -
i have c program makes memory request. after run program use free -g -t command see memory used. program call malloc function, not call free function. example: pointer=malloc(900000000*sizeof(double)) thought that called occupy ram memory when used free command free memory not change . 6 mega. run program lot of times. program don t free memory free memory not change. thouhgt operation free memory in charge of programmer in c. program more complicated that, main operation that. don t underestand why free (and occupped) memory not change. can helpe me? again, sorry english.
as jonathan leffler says in comment, malloc() not allocate memory ask in physical memory, happens first when use memory. if write memory got malloc() see memory usage seen "free" increase.
from malloc man page under notes:
by default, linux follows optimistic memory allocation strategy. means when malloc() returns non-null there no guarantee memory available.
"free" reports physical memory usage, mentioned in free man page
Comments
Post a Comment