在 使用 Xcode 检查内存泄露时(cmd+shift+B)运行,出现了一个警告:nil returned from a method that is expected to return a non-null value iOS 原因是返回了一个 不能为空 的对象. 解决方案:使用 abort() 函数: The abort() function is marked with __attribute__((noreturn)), therefore the compiler will not
在Java中内存泄漏是指某个(某些)对象已经不再被使用,应该被GC所回收的空间,但有一个对象持有这个对象的引用从而阻止这个对象被回收.比如我们通常会这样创建一个View, TextView tv = new TextView(this); 这里的this通常都是Activity,所以这个TextView就持有着这个Activity的引用.下面看张图: 通常情况下,当用户转动手机的时候,android会重新调用OnCreate()方法生成一个新的Activity,原来的 Activity应该被GC