/etc/mongod.conf中storage.wiredTiger.engineConfig.cacheSizeGB参数设置,建议为系统可用内存的60%左右。vm.swappiness=0减少交换,避免内存不足时使用磁盘。db.serverStatus().mem查看内存使用详情(常驻、虚拟、映射内存);top -p $(pidof mongod)或free -m监控进程内存占用。mongostat、mongotop实时监控内存及性能指标。maxPoolSize和空闲时间maxIdleTimeMS。db.adminCommand({setParameter: 1, tcmallocAggressiveMemoryDecommit: 1})。