内存保护模式
2026/9/28开局与日常维护8.0.0大约 4 分钟
内存保护模式
FortiGate 的内存由系统内所有功能共享。当可用内存很低时,FortiOS 会进入内存保护模式(conserve mode),降低部分功能的资源消耗,避免系统因内存耗尽而失去稳定性。进入该模式后,Antivirus 和 IPS 的检查行为可能发生变化,设备也可能拒绝新建会话。
触发机制
FortiGate 的内存保护可分为 proxy conserve mode 和 kernel conserve mode:
- proxy conserve mode:通常在某条启用了 proxy 模式检查的防火墙策略处理流量时触发。触发条件取决于可用内存,不同型号的进入和退出阈值可能不同。常见原因不是单个进程占用过高,而是 proxy 为缓存待检查内容所使用的共享内存(SHM)增长。SHM 还可能被日志、隔离区等缓冲区使用,并不会完整显示在
diagnose sys top的进程内存列中。 - kernel conserve mode:由系统级内存压力触发。当前 FortiOS 使用
red、green和extreme百分比阈值控制进入保护模式、退出保护模式以及丢弃新会话的时机。
red 和 green 形成进入/退出保护模式的滞回区间,可以避免内存使用率在临界值附近波动时反复切换状态。
内存阈值
可以在 config system global 中配置三个内存使用率阈值:
config system global
set memory-use-threshold-extreme <percent>
set memory-use-threshold-green <percent>
set memory-use-threshold-red <percent>
end| 参数 | 作用 | 范围和默认值 |
|---|---|---|
memory-use-threshold-extreme | 内存使用率达到该阈值后视为 extreme,FortiGate 丢弃新会话。 | 70~97,默认 95 |
memory-use-threshold-red | 内存使用率达到该阈值后进入内存保护模式。 | 70~97,默认 88 |
memory-use-threshold-green | 内存使用率降至该阈值后退出内存保护模式。 | 70~97,默认 82 |
重要
阈值按设备总 RAM 的百分比计算。修改阈值会改变设备进入保护模式和丢弃新会话的时机,应结合设备型号、业务流量和内存趋势评估后再调整。
proxy 模式策略在内存保护模式下的行为
防火墙策略启用 proxy 模式时,Antivirus 行为由 av-failopen 控制:
config system global
set av-failopen {pass | off | one-shot}
endpass:默认值。绕过 Antivirus proxy,允许流量继续转发。启用了 Antivirus proxy 的防火墙策略也会绕过相关代理检查;不依赖代理的防火墙策略仍然生效。适用于业务可用性优先、需要先恢复访问的场景。off:停止所有匹配启用 Antivirus proxy 的防火墙策略的流量。新会话会被阻断,已有会话继续处理;如果已有会话需要更多内存,也可能被终止。仅启用 IPS 的防火墙策略可以继续工作,同时启用 Antivirus 和 IPS 的防火墙策略会被阻断。适用于安全性优先的场景。one-shot:对启用了 Antivirus proxy 的防火墙策略绕过代理检查。即使设备退出内存保护模式,绕过仍会持续,直到修改av-failopen或重启设备。
flow 模式策略在内存保护模式下的行为
当流量匹配启用 flow 模式检查的防火墙策略时,其 IPS 行为由 config ips global 下的 fail-open 控制:
config ips global
set fail-open {enable | disable}
enddisable:默认值。IPS 引擎丢弃所有需要流模式检查的新会话。enable:IPS 引擎不执行扫描,允许新数据包通过。
查看保护状态
进入内存保护模式时,FortiOS 会生成内存保护模式日志和 SNMP trap,GUI 顶部也会显示横幅:

查看内存状态
在 CLI 中执行以下命令:
# diagnose hardware sysinfo conserve
memory conserve mode: on
total RAM: 997 MB
memory used: 735 MB 73% of total RAM
memory freeable: 173 MB 17% of total RAM
memory used + freeable threshold extreme: 947 MB 95% of total RAM
memory used threshold red: 877 MB 88% of total RAM
memory used threshold green: 817 MB 82% of total RAMmemory conserve mode:当前是否处于内存保护模式。memory used和memory freeable:当前已使用及可释放的内存。threshold extreme、threshold red和threshold green:当前生效的三个阈值。
查看系统事件日志
date=2022-11-02 time=16:58:37 logid="0100022011" type="event" subtype="system" level="critical" vd="root" logdesc="Memory conserve mode entered" service="kernel" conserve="on" total=997 MB used=707 MB red="877 MB" green="698 MB" msg="Kernel enters memory conserve mode"查看 crashlog
# diagnose debug crashlog read
1: 2022-10-27 14:22:36 service=kernel conserve=on total="997 MB" used="720 MB" red="877 MB"
2: 2022-10-27 14:22:36 green="817 MB" msg="Kernel enters memory conserve mode"排查建议
提示
如果设备反复进入内存保护模式,建议同时记录 diagnose hardware sysinfo conserve 的阈值和内存趋势,并结合开局与日常维护 → 2GB 内存设备配置优化和故障排查 → AV/IPS 内存高排查进行分析。如果设备部署了 HA,并希望在内存持续升高时提前将业务切换到内存占用较低的成员,可参考 HA 双机热备 → HA 内存高触发切换。