in Education by
I am observing the following behavior in my test program: I am doing malloc() for 1 MB and then free() it after sleep(10). I am doing this five times. I am observing memory consumption in top while the program is running. Once free()-d, I am expecting the program's virtual memory (VIRT) consumption to be down by 1 MB. But actually it isn't. It stays stable. What is the explanation for this behavior? Does malloc() do some reserve while allocating memory? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Once free()-d, I am expecting program's virtual memory (VIRT) consumption to be down by 1MB. Well, this is not guaranteed by the C standard. It only says, once you free() the memory, you should not be accessing that any more. Whether the memory block is actually returned to the available memory pool or kept aside for future allocations is decided by the memory manager.

Related questions

0 votes
    Background: I need to reserve an amount of memory below 0xA0000 prior to my operating system starts. To do ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 17, 2022 in Education by JackTerrance
0 votes
    Background: I need to reserve an amount of memory below 0xA0000 prior to my operating system starts. To do ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 17, 2022 in Education by JackTerrance
0 votes
    Distinguish between malloc() & calloc() memory allocation?...
asked Jan 17, 2021 in Technology by JackTerrance
+1 vote
    Distinguish between malloc() & calloc() memory allocation....
asked Nov 9, 2020 in Technology by JackTerrance
0 votes
    What does the Central Reserve Policy Force do? Please answer the above question....
asked Aug 14, 2022 in Education by JackTerrance
0 votes
    Mention what is the difference between the "residual payment" and "partial payment" methods of allocating cash in account receivable?...
asked Jan 5, 2021 in Technology by JackTerrance
0 votes
    Which is more effective while calling the C++ functions? a) call by object b) call by pointer c) call by value d) call by reference...
asked Oct 19, 2022 in Education by JackTerrance
0 votes
    A ______ file system is software that enables multiple computers to share file storage while maintaining ... Storage Structure in portion Transactions of Database Management...
asked Oct 10, 2021 in Education by JackTerrance
0 votes
    We have a large ec2 instance running in Asia pacific region. We want to reserve that particular instance.In aws ... out on something Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    When a program tries to access a page that is mapped in address space but not loaded in physical memory, then ____________ ... error occurs c) page fault occurs d) no error occurs...
asked Oct 27, 2022 in Education by JackTerrance
0 votes
    The maximum memory space addressable by 8086 processor was? 64 KB 640KB 1MB 2MB...
asked May 1, 2021 in Education by JackTerrance
0 votes
    What is the return value of malloc (0)?...
asked Jan 23, 2021 in Technology by JackTerrance
0 votes
    Is it better to use malloc () or calloc ()?...
asked Jan 23, 2021 in Technology by JackTerrance
0 votes
    What is the difference between malloc and calloc?...
asked Jan 23, 2021 in Technology by JackTerrance
...