一次php请求到来, phpf-pm 调度php, shmop_open 打开文件, 载入内存.
请求执行完成. GeoIP class __destruct 的时候会调用 shmop_close.
通过在 fopen , shmop_close 埋点, 后续请求 shmop_open 可以直接打开共享内存, 不需要再次把 文件 读入 内存.
通过 ipcs -m 查看:
key shmid owner perms bytes nattch status
0x3f425f42 0 www 600 1156206704 0
free -m
total used free shared buff/cache available
Mem: 15868 684 3101 1105 12083 13749
echo 3 > /proc/sys/vm/drop_caches 后 free -m
total used free shared buff/cache available
Mem: 15868 679 13896 1105 1293 13825
并没能清理 共享内存.
ipcrm -m 0 才能删掉. 同时 埋点显示, 重新 open了磁盘文件, 载入到共享内存.