mac'purge'命令真的有用吗?

use*_*445 1 c macos purge systems-programming

我使用mac机器,我对mac的purge命令的概念有好奇心.

当我执行该命令时,它释放了一些像垃圾一样的记忆(它真的对吗?)

我在本学期学习了"系统编程"中的虚拟内存概念,但我不知道这种清除是如何实现的.

所以我的问题是

  1. 如何清除可以区分仍然使用分配的内存块和垃圾?

  2. C中是否有任何小工具或相同的功能?

Ram*_*uri 8

你让我好奇,因为我不知道什么是purge命令,所以我在终端上键入man purge:

NAME
     purge -- force disk cache to be purged (flushed and emptied)

SYNOPSIS
     purge

DESCRIPTION
     Purge can be used to approximate initial boot conditions with a cold disk
     buffer cache for performance analysis. It does not affect anonymous mem-
     ory that has been allocated through malloc, vm_allocate, etc.

SEE ALSO
     sync(8), malloc(3)
Run Code Online (Sandbox Code Playgroud)

所以它删除了缓存.