Why does the free() function not return memory to the operating system?

后端 未结 2 1534
长情又很酷
长情又很酷 2020-12-06 23:07

When I use the top terminal program at Linux, I can\'t see the result of free.

My expectation is:

  1. free map and list.

2条回答
  •  不思量自难忘°
    2020-12-06 23:48

    The heap typically uses operating system functions to manage its memory. The heap’s size may be fixed when the program is created, or it may be allowed to grow. However, the heap manager does not necessarily return memory to the operating system when the free function is called. The deallocated memory is simply made available for subsequent use by the application. Thus, when a program allocates and then frees up memory, the deallocation of memory is not normally reflected in the application’s memory usage as seen from the operating system perspective.

提交回复
热议问题