案例一: User public class User { } UserSizeTest public class UserSizeTest { static final Runtime runTime=Runtime.getRuntime(); public static void main(String[] args) { final int count = 100000; User[] us=new User[count]; long heap1 = 0; for (int i = -1;
Android程序中一旦加载的图片比较多,就有可能出现Out of Memory而导致程序崩溃.这个一方面是因为Android系统本身对于每个单独的进程有内存大小的限制(有16M,64M,128M,256M等等),另一方面是因为Android系统对于图片资源的垃圾回收比较慢(文章http://jiangnane.com/index.php/archives/230中对Android源码进行了分析,发现Android的setImageViewBitmap(Bitmap bm)方法的源码中没有建立新
public class test { private static java.util.HashMap<String, String> needQueryResProductList = new java.util.HashMap<String, String>(); public static void main(String[] args) throws Exception { String userlabel="12345678998765432100"
from sys import getsizeof class A(object): pass class B: pass for x in (None, 1, 1L, 1.2, 'c', [], (), {}, set(), B, B(), A, A()): print "{0:20s}\t{1:d}".format(type(x).__name__, sys.getsizeof(x)) NoneType 16 int 24 long 28 float 24 str 34 list