且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

检测内存不足错误

更新时间:2022-06-27 00:08:51

您可以使用内存不足警告系统;这个 http://www.javaspecialists.eu/archive/Issue092.html 可以灵感。您可以配置在某个内存阈值(例如80%)被触发后调用的侦听器 - 您可以使用此调用开始采取纠正措施。

You could use an out of memory warning system; this http://www.javaspecialists.eu/archive/Issue092.html can be an inspiration. You could configure a listener which is invoked after a certain memory threshold ( say 80%) is breached - you can use this invocation to start taking corrective measures.

我们使用某些东西类似地,当组件的内存阈值达到80%并启动清理操作时,我们暂停组件的服务;只有当使用的内存低于另一个可配置值阈值时,组件才会返回。

We use something similar, where we suspend the component's service when the memory threshold of the component reaches 80% and start the clean up action; the component comes back only when the used memory comes below a another configurable value threshold.