当内存不足时自动警告 Java 应用程序的好方法是什么?
当可用内存达到某个阈值时,是否有一种优雅的方法可以自动向我的 Java 应用程序发出内存警告?
请注意,这是一个 Jeopardy 风格的问题,我已经有了答案,只是想将其发布在这里供全世界发现,因为该解决方案对我有很大帮助。
Is there an elegant way to automatically fire memory warnings to my Java application when free memory reaches a certain threshold?
Note that this is a Jeopardy-style question to which I already have an answer, just wanted to post it here for the world to discover because the solution helped me a bunch.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是 Heinz Kabutz 编写的一个很棒的小课程,它对我来说“开箱即用”,完美无缺。在旧的“Java Specialists”问题中找到它:http://www.javaspecialists.eu/archive/Issue092.html
用法:
Here's a great little class written by Heinz Kabutz that works flawlessly for me "out of the box". Found it in an old "Java specialists" issue: http://www.javaspecialists.eu/archive/Issue092.html
Usage: