##########################################################################
# File Name: adb.sh
# Author: Arctan
# mail:2757904225@qq.com
# Created Time: Thu 15 Aug 2019 08:09:44 PM PDT
#########################################################################
#!/bin/sh
while true
do
delay=3
# sleep $(delay)
# dumpsys meminfo com.bonade.multiplefacerecognition |grep -m 1 "Native Heap"
# dumpsys meminfo com.srt.mypc.myactivity |grep -m 1 "Native Heap"
dumpsys meminfo com.srt.mypc.myactivity |grep -m 1 "Dalvik Heap"
done
测试代码
package com.srt.mypc.myactivity; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import java.util.Vector; import static java.lang.Thread.sleep; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.myactivity); new Thread(new Runnable() { @Override public void run() { //需要执行的代码 heapTest(); } }).start(); } public void heapTest(){ Vector<int []> v = new Vector<int []>(); for(;;){ v.add(new int[1024*10*10*2]); //abc=null; try{ Thread.sleep(1000); }catch (Exception e){ e.printStackTrace(); } } } }
AndroidMainfest.xml
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.srt.mypc.myactivity"> <application android:largeHeap="true" android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>