LINUX内存溢出问题,修改内存回收机制
Last updated
2023-01-28 10:46:36
{"value":"### 1.\u68c0\u67e5\u5185\u5b58\n\n**\u9996\u5148\u67e5\u770b\u5185\u5b58\u662f\u5426\u5145\u8db3\uff0c\u6267\u884cfree -h;**\n\n\u547d\u4ee4\u53c2\u6570\u89e3\u91ca\uff1a\ntotal\uff1a\u8868\u793a \u603b\u8ba1\u7269\u7406\u5185\u5b58\u7684\u5927\u5c0f\u3002\nused\uff1a\u8868\u793a \u5df2\u4f7f\u7528\u591a\u5c11\u3002\nfree\uff1a\u8868\u793a \u53ef\u7528\u5185\u5b58\u591a\u5c11\u3002\nShared\uff1a\u8868\u793a\u591a\u4e2a\u8fdb\u7a0b\u5171\u4eab\u7684\u5185\u5b58\u603b\u989d\u3002\nBuffers\/cached\uff1a\u8868\u793a \u78c1\u76d8\u7f13\u5b58\u7684\u5927\u5c0f\u3002\n\n### 2.\u68c0\u67e5\u914d\u7f6e\n\n**\u770b\u5185\u5b58\u81ea\u52a8\u91ca\u653e\u7684\u914d\u7f6ecat \/proc\/sys\/vm\/drop_caches**\n\n\u53c2\u6570\u89e3\u91ca\uff1a\n0 \u4e0d\u91ca\u653e\u5185\u5b58\n1 \u91ca\u653e\u9875\u9762\u7f13\u5b58\n2 \u91ca\u653e\u6570\u636e\u533a\u548c\u4fe1\u606f\u8282\u70b9\n3 \u91ca\u653e\u9875\u9762\u7f13\u5b58\uff0c\u6570\u636e\u533a\u548c\u4fe1\u606f\u8282\u70b9\n\n### 3.\u4e34\u65f6\u91ca\u653e\u5185\u5b58\n\n**\u4e34\u65f6\u91ca\u653e\u5185\u5b58\u7684\u65b9\u6cd5\uff08\u6267\u884c\u5728\u6267\u884c\u7684\u65f6\u5019\u624d\u4f1a\u751f\u6548\uff09\uff1a**\n\n\u5148\u6267\u884csync\u8fdb\u884c\u6570\u636e\u540c\u6b65\uff0c\u9632\u6b62\u4e22\u5931\u6570\u636e\uff0c\u518d\u6267\u884cecho 3 > \/proc\/sys\/vm\/drop_caches\u91ca\u653e\u6240\u6709\u7684\uff08\u6ce8\u610f\u8be5\u6587\u4ef6\u4e2d\u7684\u503c\u9ed8\u8ba4\u662f0\uff0c\u66f4\u6539\u540e\u662f\u6ca1\u6709\u529e\u6cd5\u66f4\u6539\u56de0\u7684\uff0c\u539f\u56e0\u662f0\u53ea\u662f\u7cfb\u7edf\u6700\u5f00\u59cb\u4f7f\u7528\u7684\u503c\uff0c\u662f\u81ea\u52a8\u5206\u914d\u7684\uff0c\u771f\u6b63\u7684\u53c2\u6570\u53ea\u67091\u52303\uff09\n\n### 4.\u6c38\u4e45\u91ca\u653e\u5185\u5b58\n\n**\u6c38\u4e45\u91ca\u653e\u5185\u5b58\u7684\u65b9\u6cd5\uff1a**\n\n\u6267\u884cvi \/etc\/sysctl.conf \n\u5728\u8fd9\u4e2a\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4e00\u884cvm.drop_caches=3\u5c31\u53ef\u4ee5\u6c38\u4e45\u91ca\u653e\u5185\u5b58\uff08\u6ce8\u610f\uff1a\u4f7f\u7528\u6c38\u4e45\u751f\u6548\u65f6\u4f1a\u5f71\u54cd\u6574\u4e2a\u7cfb\u7edf\u7684\u6027\u80fd\uff09\n\n### 5.\u5b9a\u65f6\u6e05\u7406\u5185\u5b58\n\n**\u6216\u8005\u53ef\u4ee5\u4f7f\u7528\u5b9a\u65f6\u4efb\u52a1\u7684\u65b9\u5f0f\uff0c\u5b9a\u65f6\u6e05\u7406\u5185\u5b58**\n\n\u4f8b\u5b50\uff1a\n\u5728\u8fd9\u91cc\u5177\u4f53\u4f7f\u7528\u7684\u7f16\u5199\u4e00\u4e2a\u5b9a\u65f6\u4efb\u52a1\uff1a\n\u6267\u884ccrontab -e\u00a0\u6dfb\u52a0\u5b9a\u65f6\u4efb\u52a1 relaseMem \n\uff085\u4e2a\u661f\u4e3a\u522b\u662f \n\u5206 \u65f6 \u65e5 \u6708 \u5468 \uff08\u6b64\u5904\u662f\u6bcf\u5929\u6267\u884c\uff09\uff09\n\n\u8f93\u5165\uff1a\n\n![](https:\/\/97yw3pix.hk03.1112oss.com\/TechnicalQA%2F%E6%96%87%E6%A1%A3%2Fweek6%2FLINUX%E5%86%85%E5%AD%98%E6%BA%A2%E5%87%BA%E9%97%AE%E9%A2%98%EF%BC%8C%E4%BF%AE%E6%94%B9%E5%86%85%E5%AD%98%E5%9B%9E%E6%94%B6%E6%9C%BA%E5%88%B6%2F1.png)\n\u6267\u884c vim \/root\/relaseMem\n\n\u5199\u5165\u811a\u672c\uff1a\n\n![](https:\/\/97yw3pix.hk03.1112oss.com\/TechnicalQA%2F%E6%96%87%E6%A1%A3%2Fweek6%2FLINUX%E5%86%85%E5%AD%98%E6%BA%A2%E5%87%BA%E9%97%AE%E9%A2%98%EF%BC%8C%E4%BF%AE%E6%94%B9%E5%86%85%E5%AD%98%E5%9B%9E%E6%94%B6%E6%9C%BA%E5%88%B6%2F2.png)\n\n\u53c2\u6570\u8be6\u89e3\n\n![](https:\/\/97yw3pix.hk03.1112oss.com\/TechnicalQA%2F%E6%96%87%E6%A1%A3%2Fweek6%2FLINUX%E5%86%85%E5%AD%98%E6%BA%A2%E5%87%BA%E9%97%AE%E9%A2%98%EF%BC%8C%E4%BF%AE%E6%94%B9%E5%86%85%E5%AD%98%E5%9B%9E%E6%94%B6%E6%9C%BA%E5%88%B6%2F3.png)\n\n"}