
不知道 Netbeans 是怎麼做的。後來上網查了一下, JDK 1.5 後提供了 java.lang.management.MemoryMXBean,可以讓我們偵測目前記憶體的用量及狀態:
上面這程式可以列出目前記憶體的使用狀態。
參考資料:
How do you detect low memory situations within the java virtual machine?
J2SE5.0新特性之監控與管理
參考資料:
How do you detect low memory situations within the java virtual machine?
J2SE5.0新特性之監控與管理