【开源中国 APP 全新上线】“动弹” 回归、集成大模型对话、畅读技术报告”
@老古董 竟然问我这样的问题,好嘛,我转述于此。
如果用java创建一个内存泄露?stupid question,哈哈哈。
大家编编看吧
import java.lang.reflect.Constructor; import java.lang.reflect.Field; import sun.misc.Unsafe; public class TestUnsafe { public static void main(String[] args) throws Exception{ Class unsafeClass = Class.forName("sun.misc.Unsafe"); Field f = unsafeClass.getDeclaredField("theUnsafe"); f.setAccessible(true); Unsafe unsafe = (Unsafe) f.get(null); System.out.print("4..3..2..1..."); try { for(;;) unsafe.allocateMemory(1024*1024); } catch(Error e) { System.out.println("Boom :)"); e.printStackTrace(); } } }
泄了能肿末样啊?
这篇文章吧各种情况列举了一遍还有例子。
http://www.iteye.com/topic/802573
泄了能肿末样啊?
这篇文章吧各种情况列举了一遍还有例子。
http://www.iteye.com/topic/802573