1. 在最近做的工程中发现加载的图片太多或图片过大时经常出现OOM问题,找网上资料也提供了很多方法,但自己感觉有点乱,特此,今天在不同型号的三款安卓手机上做了测试,因为有效果也有结果,今天小马就做个详细的总结,以供朋友们共同交流学习,也供自己以后在解决OOM问题上有所提高,提前讲下,片幅有点长,涉及的东西太多,大家耐心看,肯定有收获的,里面的很多东西小马也是学习参考网络资料使用的,先来简单讲下下:
  2. 一般我们大家在遇到内存问题的时候常用的方式网上也有相关资料,大体如下几种:
  3. 一:在内存引用上做些处理,常用的有软引用、强化引用、弱引用
  4. 二:在内存中加载图片时直接在内存中做处理,如:边界压缩
  5. 三:动态回收内存
  6. 四:优化Dalvik虚拟机的堆内存分配
  7. 五:自定义堆内存大小
  8. 可是真的有这么简单吗,就用以上方式就能解决OOM了?不是的,继续来看...
  9. 下面小马就照着上面的次序来整理下解决的几种方式,数字序号与上面对应:
  10. :软引用(SoftReference)、虚引用(PhantomRefrence)、弱引用(WeakReference),这三个类是对heapjava对象的应用,通过这个三个类可以和gc做简单的交互,除了这三个以外还有一个是最常用的强引用
  11. 1.1:强引用,例如下面代码:
  12. Object o=new Object();
  13. Object o1=o;
  14. 上面代码中第一句是在heap堆中创建新的Object对象通过o引用这个对象,第二句是通过o建立o1new Object()这个heap堆中的对象的引用,这两个引用都是强引用.只要存在对heap中对象的引用,gc就不会收集该对象.如果通过如下代码:
  15. o=null;
  16. o1=null
  17. heap中对象有强可及对象、软可及对象、弱可及对象、虚可及对象和不可到达对象。应用的强弱顺序是强、软、弱、和虚。对于对象是属于哪种可及的对象,由他的最强的引用决定。如下:
  18. String abc=new String("abc"); //1
  19. SoftReference<String> abcSoftRef=new SoftReference<String>(abc); //2
  20. WeakReference<String> abcWeakRef = new WeakReference<String>(abc); //3
  21. abc=null; //4
  22. abcSoftRef.clear();//5
  23. 上面的代码中:
  24. 第一行在heap对中创建内容为“abc”的对象,并建立abc到该对象的强引用,该对象是强可及的。第二行和第三行分别建立对heap中对象的软引用和弱引用,此时heap中的对象仍是强可及的。第四行之后heap中对象不再是强可及的,变成软可及的。同样第五行执行之后变成弱可及的。
  25. 1.2:软引用
  26. 软引用是主要用于内存敏感的高速缓存。在jvm报告内存不足之前会清除所有的软引用,这样以来gc就有可能收集软可及的对象,可能解决内存吃紧问题,避免内存溢出。什么时候会被收集取决于gc的算法和gc运行时可用内存的大小。当gc决定要收集软引用是执行以下过程,以上面的abcSoftRef为例:
  27.  
  28. 首先将abcSoftRefreferent设置为null,不再引用heap中的new String("abc")对象。
  29. heap中的new String("abc")对象设置为可结束的(finalizable)。
  30. heap中的new String("abc")对象的finalize()方法被运行而且该对象占用的内存被释放, abcSoftRef被添加到它的ReferenceQueue中。
  31. 注:对ReferenceQueue软引用和弱引用可以有可无,但是虚引用必须有,参见:
  32. Reference(T paramT, ReferenceQueue<? super T>paramReferenceQueue)
  33. Soft Reference 指到的对象,即使没有任何 Direct Reference,也不会被清除。一直要到 JVM 内存不足且 没有 Direct Reference 时才会清除,SoftReference 是用来设计 object-cache 之用的。如此一来 SoftReference 不但可以把对象 cache 起来,也不会造成内存不足的错误 OutOfMemoryError)。我觉得 Soft Reference 也适合拿来实作 pooling 的技巧。
  34. A obj = new A();
  35. Refenrence sr = new SoftReference(obj);
  36.  
  37. //引用时
  38. if(sr!=null){
  39. obj = sr.get();
  40. }else{
  41. obj = new A();
  42. sr = new SoftReference(obj);
  43. }
  44. 1.3:弱引用
  45. gc碰到弱可及对象,并释放abcWeakRef的引用,收集该对象。但是gc可能需要对此运用才能找到该弱可及对象。通过如下代码可以了明了的看出它的作用:
  46. String abc=new String("abc");
  47. WeakReference<String> abcWeakRef = new WeakReference<String>(abc);
  48. abc=null;
  49. System.out.println("before gc: "+abcWeakRef.get());
  50. System.gc();
  51. System.out.println("after gc: "+abcWeakRef.get());
  52. 运行结果:
  53. before gc: abc
  54. after gc: null
  55. gc收集弱可及对象的执行过程和软可及一样,只是gc不会根据内存情况来决定是不是收集该对象。如果你希望能随时取得某对象的信息,但又不想影响此对象的垃圾收集,那么你应该用 Weak Reference 来记住此对象,而不是用一般的 reference
  56.  
  57. A obj = new A();
  58.  
  59. WeakReference wr = new WeakReference(obj);
  60.  
  61. obj = null;
  62.  
  63. //等待一段时间,obj对象就会被垃圾回收
  64.   ...
  65.  
  66.   if (wr.get()==null) {
  67.   System.out.println("obj 已经被清除了 ");
  68.   } else {
  69.   System.out.println("obj 尚未被清除,其信息是 "+obj.toString());
  70.   }
  71.   ...
  72. }
  73.  
  74. 在此例中,透过 get() 可以取得此 Reference 的所指到的对象,如果返回值为 null 的话,代表此对象已经被清除。这类的技巧,在设计 Optimizer Debugger 这类的程序时常会用到,因为这类程序需要取得某对象的信息,但是不可以 影响此对象的垃圾收集。
  75.  
  76. 1.4:虚引用
  77.  
  78. 就是没有的意思,建立虚引用之后通过get方法返回结果始终为null,通过源代码你会发现,虚引用通向会把引用的对象写进referent,只是get方法返回结果为null.先看一下和gc交互的过程在说一下他的作用.
  79. 1.4. 不把referent设置为null, 直接把heap中的new String("abc")对象设置为可结束的(finalizable).
  80. 1.4. 与软引用和弱引用不同, 先把PhantomRefrence对象添加到它的ReferenceQueue中.然后在释放虚可及的对象.
  81. 你会发现在收集heap中的new String("abc")对象之前,你就可以做一些其他的事情.通过以下代码可以了解他的作用.
  82.  
  83. import java.lang.ref.PhantomReference;
  84. import java.lang.ref.Reference;
  85. import java.lang.ref.ReferenceQueue;
  86. import java.lang.reflect.Field;
  87.  
  88. public class Test {
  89. public static boolean isRun = true;
  90.  
  91. public static void main(String[] args) throws Exception {
  92. String abc = new String("abc");
  93. System.out.println(abc.getClass() + "@" + abc.hashCode());
  94. final ReferenceQueue referenceQueue = new ReferenceQueue<String>();
  95. new Thread() {
  96. public void run() {
  97. while (isRun) {
  98. Object o = referenceQueue.poll();
  99. if (o != null) {
  100. try {
  101. Field rereferent = Reference.class
  102. .getDeclaredField("referent");
  103. rereferent.setAccessible(true);
  104. Object result = rereferent.get(o);
  105. System.out.println("gc will collect:"
  106. + result.getClass() + "@"
  107. + result.hashCode());
  108. } catch (Exception e) {
  109.  
  110. e.printStackTrace();
  111. }
  112. }
  113. }
  114. }
  115. }.start();
  116. PhantomReference<String> abcWeakRef = new PhantomReference<String>(abc,
  117. referenceQueue);
  118. abc = null;
  119. Thread.currentThread().sleep();
  120. System.gc();
  121. Thread.currentThread().sleep();
  122. isRun = false;
  123. }
  124.  
  125. }
  126.  
  127. 结果为
  128. class java.lang.String@
  129. gc will collect:class java.lang.String@ 好了,关于引用就讲到这,下面看2
  130.  
  131. :在内存中压缩小马做了下测试,对于少量不太大的图片这种方式可行,但太多而又大的图片小马用个笨的方式就是,先在内存中压缩,再用软引用避免OOM,两种方式代码如下,大家可参考下:
  132. 方式一代码如下:
  133. @SuppressWarnings("unused")
  134. private Bitmap copressImage(String imgPath){
  135. File picture = new File(imgPath);
  136. Options bitmapFactoryOptions = new BitmapFactory.Options();
  137. //下面这个设置是将图片边界不可调节变为可调节
  138. bitmapFactoryOptions.inJustDecodeBounds = true;
  139. bitmapFactoryOptions.inSampleSize = ;
  140. int outWidth = bitmapFactoryOptions.outWidth;
  141. int outHeight = bitmapFactoryOptions.outHeight;
  142. bmap = BitmapFactory.decodeFile(picture.getAbsolutePath(),
  143. bitmapFactoryOptions);
  144. float imagew = ;
  145. float imageh = ;
  146. int yRatio = (int) Math.ceil(bitmapFactoryOptions.outHeight
  147. / imageh);
  148. int xRatio = (int) Math
  149. .ceil(bitmapFactoryOptions.outWidth / imagew);
  150. if (yRatio > || xRatio > ) {
  151. if (yRatio > xRatio) {
  152. bitmapFactoryOptions.inSampleSize = yRatio;
  153. } else {
  154. bitmapFactoryOptions.inSampleSize = xRatio;
  155. }
  156.  
  157. }
  158. bitmapFactoryOptions.inJustDecodeBounds = false;
  159. bmap = BitmapFactory.decodeFile(picture.getAbsolutePath(),
  160. bitmapFactoryOptions);
  161. if(bmap != null){
  162. //ivwCouponImage.setImageBitmap(bmap);
  163. return bmap;
  164. }
  165. return null;
  166. }
  167. 方式二代码如下:
  168. package com.lvguo.scanstreet.activity;
  169.  
  170. import java.io.File;
  171. import java.lang.ref.SoftReference;
  172. import java.util.ArrayList;
  173. import java.util.HashMap;
  174. import java.util.List;
  175. import android.app.Activity;
  176. import android.app.AlertDialog;
  177. import android.content.Context;
  178. import android.content.DialogInterface;
  179. import android.content.Intent;
  180. import android.content.res.TypedArray;
  181. import android.graphics.Bitmap;
  182. import android.graphics.BitmapFactory;
  183. import android.graphics.BitmapFactory.Options;
  184. import android.os.Bundle;
  185. import android.view.View;
  186. import android.view.ViewGroup;
  187. import android.view.WindowManager;
  188. import android.widget.AdapterView;
  189. import android.widget.AdapterView.OnItemLongClickListener;
  190. import android.widget.BaseAdapter;
  191. import android.widget.Gallery;
  192. import android.widget.ImageView;
  193. import android.widget.Toast;
  194. import com.lvguo.scanstreet.R;
  195. import com.lvguo.scanstreet.data.ApplicationData;
  196. /**
  197. * @Title: PhotoScanActivity.java
  198. * @Description: 照片预览控制类
  199. * @author XiaoMa
  200. */
  201. public class PhotoScanActivity extends Activity {
  202. private Gallery gallery ;
  203. private List<String> ImageList;
  204. private List<String> it ;
  205. private ImageAdapter adapter ;
  206. private String path ;
  207. private String shopType;
  208. private HashMap<String, SoftReference<Bitmap>> imageCache = null;
  209. private Bitmap bitmap = null;
  210. private SoftReference<Bitmap> srf = null;
  211.  
  212. @Override
  213. public void onCreate(Bundle savedInstanceState) {
  214. super.onCreate(savedInstanceState);
  215. getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
  216. WindowManager.LayoutParams.FLAG_FULLSCREEN);
  217. setContentView(R.layout.photoscan);
  218. Intent intent = this.getIntent();
  219. if(intent != null){
  220. if(intent.getBundleExtra("bundle") != null){
  221. Bundle bundle = intent.getBundleExtra("bundle");
  222. path = bundle.getString("path");
  223. shopType = bundle.getString("shopType");
  224. }
  225. }
  226. init();
  227. }
  228.  
  229. private void init(){
  230. imageCache = new HashMap<String, SoftReference<Bitmap>>();
  231. gallery = (Gallery)findViewById(R.id.gallery);
  232. ImageList = getSD();
  233. if(ImageList.size() == ){
  234. Toast.makeText(getApplicationContext(), "无照片,请返回拍照后再使用预览", Toast.LENGTH_SHORT).show();
  235. return ;
  236. }
  237. adapter = new ImageAdapter(this, ImageList);
  238. gallery.setAdapter(adapter);
  239. gallery.setOnItemLongClickListener(longlistener);
  240. }
  241.  
  242. /**
  243. * Gallery长按事件操作实现
  244. */
  245. private OnItemLongClickListener longlistener = new OnItemLongClickListener() {
  246.  
  247. @Override
  248. public boolean onItemLongClick(AdapterView<?> parent, View view,
  249. final int position, long id) {
  250. //此处添加长按事件删除照片实现
  251. AlertDialog.Builder dialog = new AlertDialog.Builder(PhotoScanActivity.this);
  252. dialog.setIcon(R.drawable.warn);
  253. dialog.setTitle("删除提示");
  254. dialog.setMessage("你确定要删除这张照片吗?");
  255. dialog.setPositiveButton("确定", new DialogInterface.OnClickListener() {
  256. @Override
  257. public void onClick(DialogInterface dialog, int which) {
  258. File file = new File(it.get(position));
  259. boolean isSuccess;
  260. if(file.exists()){
  261. isSuccess = file.delete();
  262. if(isSuccess){
  263. ImageList.remove(position);
  264. adapter.notifyDataSetChanged();
  265. //gallery.setAdapter(adapter);
  266. if(ImageList.size() == ){
  267. Toast.makeText(getApplicationContext(), getResources().getString(R.string.phoSizeZero), Toast.LENGTH_SHORT).show();
  268. }
  269. Toast.makeText(getApplicationContext(), getResources().getString(R.string.phoDelSuccess), Toast.LENGTH_SHORT).show();
  270. }
  271. }
  272. }
  273. });
  274. dialog.setNegativeButton("取消",new DialogInterface.OnClickListener() {
  275. @Override
  276. public void onClick(DialogInterface dialog, int which) {
  277. dialog.dismiss();
  278. }
  279. });
  280. dialog.create().show();
  281. return false;
  282. }
  283. };
  284.  
  285. /**
  286. * 获取SD卡上的所有图片文件
  287. * @return
  288. */
  289. private List<String> getSD() {
  290. /* 设定目前所在路径 */
  291. File fileK ;
  292. it = new ArrayList<String>();
  293. if("newadd".equals(shopType)){
  294. //如果是从查看本人新增列表项或商户列表项进来时
  295. fileK = new File(ApplicationData.TEMP);
  296. }else{
  297. //此时为纯粹新增
  298. fileK = new File(path);
  299. }
  300. File[] files = fileK.listFiles();
  301. if(files != null && files.length>){
  302. for(File f : files ){
  303. if(getImageFile(f.getName())){
  304. it.add(f.getPath());
  305.  
  306. Options bitmapFactoryOptions = new BitmapFactory.Options();
  307.  
  308. //下面这个设置是将图片边界不可调节变为可调节
  309. bitmapFactoryOptions.inJustDecodeBounds = true;
  310. bitmapFactoryOptions.inSampleSize = ;
  311. int outWidth = bitmapFactoryOptions.outWidth;
  312. int outHeight = bitmapFactoryOptions.outHeight;
  313. float imagew = ;
  314. float imageh = ;
  315. int yRatio = (int) Math.ceil(bitmapFactoryOptions.outHeight
  316. / imageh);
  317. int xRatio = (int) Math
  318. .ceil(bitmapFactoryOptions.outWidth / imagew);
  319. if (yRatio > || xRatio > ) {
  320. if (yRatio > xRatio) {
  321. bitmapFactoryOptions.inSampleSize = yRatio;
  322. } else {
  323. bitmapFactoryOptions.inSampleSize = xRatio;
  324. }
  325.  
  326. }
  327. bitmapFactoryOptions.inJustDecodeBounds = false;
  328.  
  329. bitmap = BitmapFactory.decodeFile(f.getPath(),
  330. bitmapFactoryOptions);
  331.  
  332. //bitmap = BitmapFactory.decodeFile(f.getPath());
  333. srf = new SoftReference<Bitmap>(bitmap);
  334. imageCache.put(f.getName(), srf);
  335. }
  336. }
  337. }
  338. return it;
  339. }
  340.  
  341. /**
  342. * 获取图片文件方法的具体实现
  343. * @param fName
  344. * @return
  345. */
  346. private boolean getImageFile(String fName) {
  347. boolean re;
  348.  
  349. /* 取得扩展名 */
  350. String end = fName
  351. .substring(fName.lastIndexOf(".") + , fName.length())
  352. .toLowerCase();
  353.  
  354. /* 按扩展名的类型决定MimeType */
  355. if (end.equals("jpg") || end.equals("gif") || end.equals("png")
  356. || end.equals("jpeg") || end.equals("bmp")) {
  357. re = true;
  358. } else {
  359. re = false;
  360. }
  361. return re;
  362. }
  363.  
  364. public class ImageAdapter extends BaseAdapter{
  365. /* 声明变量 */
  366. int mGalleryItemBackground;
  367. private Context mContext;
  368. private List<String> lis;
  369.  
  370. /* ImageAdapter的构造符 */
  371. public ImageAdapter(Context c, List<String> li) {
  372. mContext = c;
  373. lis = li;
  374. TypedArray a = obtainStyledAttributes(R.styleable.Gallery);
  375. mGalleryItemBackground = a.getResourceId(R.styleable.Gallery_android_galleryItemBackground, );
  376. a.recycle();
  377. }
  378.  
  379. /* 几定要重写的方法getCount,传回图片数目 */
  380. public int getCount() {
  381. return lis.size();
  382. }
  383.  
  384. /* 一定要重写的方法getItem,传回position */
  385. public Object getItem(int position) {
  386. return lis.get(position);
  387. }
  388.  
  389. /* 一定要重写的方法getItemId,传并position */
  390. public long getItemId(int position) {
  391. return position;
  392. }
  393.  
  394. /* 几定要重写的方法getView,传并几View对象 */
  395. public View getView(int position, View convertView, ViewGroup parent) {
  396. System.out.println("lis:"+lis);
  397. File file = new File(it.get(position));
  398. SoftReference<Bitmap> srf = imageCache.get(file.getName());
  399. Bitmap bit = srf.get();
  400. ImageView i = new ImageView(mContext);
  401. i.setImageBitmap(bit);
  402. i.setScaleType(ImageView.ScaleType.FIT_XY);
  403. i.setLayoutParams( new Gallery.LayoutParams(WindowManager.LayoutParams.WRAP_CONTENT,
  404. WindowManager.LayoutParams.WRAP_CONTENT));
  405. return i;
  406. }
  407. }
  408. }
  409. 上面两种方式第一种直接使用边界压缩,第二种在使用边界压缩的情况下间接的使用了软引用来避免OOM,但大家都知道,这些函数在完成decode后,最终都是通过java层的createBitmap来完成的,需要消耗更多内存,如果图片多且大,这种方式还是会引用OOM异常的,不着急,有的是办法解决,继续看,以下方式也大有妙用的:
  410. . InputStream is = this.getResources().openRawResource(R.drawable.pic1);
  411. BitmapFactory.Options options=new BitmapFactory.Options();
  412. options.inJustDecodeBounds = false;
  413. options.inSampleSize = ; //width,hight设为原来的十分一
  414. Bitmap btp =BitmapFactory.decodeStream(is,null,options);
  415. . if(!bmp.isRecycle() ){
  416. bmp.recycle() //回收图片所占的内存
  417. system.gc() //提醒系统及时回收
  418. }
  419. 上面代码与下面代码大家可分开使用,也可有效缓解内存问题哦...吼吼...
  420.  
  421. /** 这个地方大家别搞混了,为了方便小马把两个贴一起了,使用的时候记得分开使用
  422. * 以最省内存的方式读取本地资源的图片
  423. */
  424. public static Bitmap readBitMap(Context context, int resId){
  425. BitmapFactory.Options opt = new BitmapFactory.Options();
  426. opt.inPreferredConfig = Bitmap.Config.RGB_565;
  427. opt.inPurgeable = true;
  428. opt.inInputShareable = true;
  429. //获取资源图片
  430. InputStream is = context.getResources().openRawResource(resId);
  431. return BitmapFactory.decodeStream(is,null,opt);
  432. }
  433. :大家可以选择在合适的地方使用以下代码动态并自行显式调用GC来回收内存:
  434. if(bitmapObject.isRecycled()==false) //如果没有回收
  435. bitmapObject.recycle();
  436. :这个就好玩了,优化Dalvik虚拟机的堆内存分配,听着很强大,来看下具体是怎么一回事
  437. 对于Android平台来说,其托管层使用的Dalvik JavaVM从目前的表现来看还有很多地方可以优化处理,比如我们在开发一些大型游戏或耗资源的应用中可能考虑手动干涉GC处理,使用 dalvik.system.VMRuntime类提供的setTargetHeapUtilization方法可以增强程序堆内存的处理效率。当然具体原理我们可以参考开源工程,这里我们仅说下使用方法: 代码如下:
  438. private final static floatTARGET_HEAP_UTILIZATION = 0.75f;
  439. 在程序onCreate时就可以调用
  440. VMRuntime.getRuntime().setTargetHeapUtilization(TARGET_HEAP_UTILIZATION);
  441. 即可
  442. :自定义我们的应用需要多大的内存,这个好暴力哇,强行设置最小内存大小,代码如下:
  443. private final static int CWJ_HEAP_SIZE = * * ;
  444. //设置最小heap内存为6MB大小
  445. VMRuntime.getRuntime().setMinimumHeapSize(CWJ_HEAP_SIZE);
  446. 好了,文章写完了,片幅有点长,因为涉及到的东西太多了,其它文章小马都会贴源码,这篇文章小马是直接在项目中用三款安卓真机测试的,有效果,项目原码就不在这贴了,不然泄密了都,吼吼,但这里讲下还是会因为手机的不同而不同,大家得根据自己需求选择合适的方式来避免OOM,大家加油呀,每天都有或多或少的收获,这也算是进步,加油加油!

Android 内存溢出解决方案(OOM) 整理总结的更多相关文章

  1. Android 内存溢出解决方案(OOM) 整理总结<转>

    在最近做的工程中发现加载的图片太多或图片过大时经常出现OOM问题,找网上资料也提供了很多方法,但自己感觉有点乱,特此,今天在不同型号的三款安卓手机上做了测试,因为有效果也有结果,今天小马就做个详细的总 ...

  2. Android内存溢出解决方案(OOM)

    众所周知,每个Android应用程序在运行时都有一定的内存限制,限制大小一般为16MB或24MB(视平台而定).因此在开发应用时需要特别关注自身的内存使用量,而一般最耗内存量的资源,一般是图片.音频文 ...

  3. Android内存溢出解决方案总结

    我的视频会议中有三个内存泄露的崆点: 1) BNLiveControlView mView = this; 未释放 (自定义view中自己引用自己造成) 2) 在自定义View中区注册了系统的网络变化 ...

  4. Android ImageSwitcher 配合Picasso解决内存溢出(OOM)问题

    最近项目中用到了 ImageSwitcher 来实现图片切换,使用起来很简单,但发现当图片比较大(超过了3M)时,程序出现了内存溢出(OOM)问题而崩溃了. 原因就是图片太大了,显示到 ImageVi ...

  5. 1篇文章搞清楚8种JVM内存溢出(OOM)的原因和解决方法

    前言 撸Java的同学,多多少少会碰到内存溢出(OOM)的场景,但造成OOM的原因却是多种多样. 堆溢出 这种场景最为常见,报错信息: java.lang.OutOfMemoryError: Java ...

  6. Android 内存溢出处理方案

    转自 : http://www.cnblogs.com/hello-ruby/archive/2013/04/19/3031098.html 首先我们来看看android内存溢出的原因,有可能是: 由 ...

  7. 应用jacob组件造成的内存溢出解决方案(java.lang.OutOfMemoryError: Java heap space)

    http://www.educity.cn/wenda/351088.html 使用jacob组件造成的内存溢出解决方案(java.lang.OutOfMemoryError: Java heap s ...

  8. PHP内存溢出解决方案

    一.内存溢出解决方案 在做数据统计分析时,经常会遇到大数组,可能会发生内存溢出,这里分享一下我的解决方案.还是用例子来说明这个问题,如下: 假定日志中存放的记录数为500000条,那么解决方案如下: ...

  9. 【转载】Android 内存溢出如何发生的。

    [转载]Android 内存溢出如何发生的. 且谈Android内存溢出 前言 关于android的内存溢出在创新文档库中也有不少,网络上也有很多这方面的资料.所以这遍文章不算是正真意义上的创新,仅仅 ...

随机推荐

  1. Java中的数组操作进阶

    package com.mi.array; import java.util.Arrays; /** * System.arraycopy(i, 0, j, 0, i.length);这种复制会覆盖目 ...

  2. 注意!你的Thread.Abort方法真的让线程停止了吗?

    大家都知道在C#里面,我们可以使用 Thread.Start方法来启动一个线程,当我们想停止执行的线程时可以使用Thread.Abort方法来强制停止正在执行的线程,但是请注意,你确定调用了Threa ...

  3. WebDriver一些常见问题的解决方法【转】

    转至:http://www.cnblogs.com/sylovezp/p/4329770.html 1.Exception NoSuchElementException: 解决方法: 1)检查目标el ...

  4. poj2407 Relatives 欧拉函数基本应用

    题意很简单 就是欧拉函数的定义: 欧拉函数是指:对于一个正整数n,小于n且和n互质的正整数(包括1)的个数,记作φ(n) .题目求的就是φ(n) 根据 通式:φ(x)=x*(1-1/p1)*(1-1/ ...

  5. 鸟哥的linux私房菜学习记录之程序管理和SElinux初探

    process是进程的意思也就是说进程是正在运行的程序 将后台程序的错误信息等等输出到某个文档 终端关闭后会停止运行,如果想终端关闭后继续运行可以使用nohup命令,man nohup.

  6. semantic-ui and IE only message

    <![if !IE]> <div class="ui message red"> <i class="close icon"> ...

  7. 10 个迅速提升你 Git 水平的提示【转】

    转自:https://www.oschina.net/translate/10-tips-git-next-level 最近我们推出了两个教程:熟悉Git的基本功能和让你在开发团队中熟练的使用Git  ...

  8. 【转载】perl接受传递参数的方法

    #! /usr/bin/perl use Getopt::Std;use warnings;use strict; sub read_from_sh($) { my $file = shift; my ...

  9. Dynamics AX 2012 R2 在增强入站端口中找不到自定义服务操作

        Reinhard写好自定义服务A,添加好服务操作A1,A2,A3.....     然后,Reinhard在增强的入站端口,选择服务操作时,却找不到这些A1,A2,A3.     查找相关资料 ...

  10. struts2结果类型

    struts2结果类型: 结果类型 描述 前request域属性是否丢失 1 dispatcher 用于与jsp整合的结果类型.默认结果类型. 2 chain Action链式处理结果类型.前一个Ac ...