{"action":"created","issue":{"url":"https://api.github.com/repos/alibaba/AndFix/issues/103","repository_url":"https://api.github.com/repos/alibaba/AndFix","labels_url":"https://api.github.com/repos/alibaba/AndFix/issues/103/labels{/name}","comments_url":"https://api.github.com/repos/alibaba/AndFix/issues/103/comments","events_url":"https://api.github.com/repos/alibaba/AndFix/issues/103/events","html_url":"https://github.com/alibaba/AndFix/issues/103","id":121971146,"number":103,"title":"被替换的方法循环执行5000次后，报错：W/dalvikvm(27735): ReferenceTable overflow (max=4096)","user":{"login":"jacpy","id":1791559,"avatar_url":"https://avatars.githubusercontent.com/u/1791559?v=3","gravatar_id":"","url":"https://api.github.com/users/jacpy","html_url":"https://github.com/jacpy","followers_url":"https://api.github.com/users/jacpy/followers","following_url":"https://api.github.com/users/jacpy/following{/other_user}","gists_url":"https://api.github.com/users/jacpy/gists{/gist_id}","starred_url":"https://api.github.com/users/jacpy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacpy/subscriptions","organizations_url":"https://api.github.com/users/jacpy/orgs","repos_url":"https://api.github.com/users/jacpy/repos","events_url":"https://api.github.com/users/jacpy/events{/privacy}","received_events_url":"https://api.github.com/users/jacpy/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2015-12-14T04:06:42Z","updated_at":"2016-09-20T02:59:15Z","closed_at":null,"body":"我是在做一个性能测试，下面代码是官方的代码，我略微修改了一下：\r\n```java\r\n\r\n/**\r\n * sample activity\r\n * \r\n * @author luohou\r\n * @author sanping.li@alipay.com\r\n * \r\n */\r\npublic class MainActivity extends Activity {\r\n\tprivate static final String TAG = \"euler\";\r\n\t\r\n\tprivate TextView mTv;\r\n\r\n\t@Override\r\n\tpublic void onCreate(Bundle savedInstanceState) {\r\n\t\tsuper.onCreate(savedInstanceState);\r\n\t\tsetContentView(R.layout.activity_main);\r\n\t\t\r\n\t\tmTv = (TextView) findViewById(R.id.txt);\r\n\t\tlong start = System.currentTimeMillis();\r\n\t\tfor (int i = 0; i < 5000; i++) {\r\n\t\t\ttest();\r\n\t\t}\r\n\t\t\r\n\t\tSystem.out.println(\"===>used time: \" + (System.currentTimeMillis() - start));\r\n\t}\r\n\t\r\n\tprivate void test() {\r\n\t\tString s = \"good\"; // 我只想修改这里\r\n\t\tFix.a(s);\r\n\t\tmTv.setText(s);\r\n//\t\tLog.e(TAG, Fix.a(\"good\"));\r\n//\t\tLog.e(TAG, \"\" + new Fix().b(\"s1\", \"s2\"));\r\n\t\t\r\n//\t\tLog.e(TAG, \"\" + new Fix());\r\n//\t\tLog.e(TAG, A.a(\"good\"));\r\n//\t\tLog.e(TAG, \"\" + new A().b(\"s1\", \"s2\"));\r\n//\t\tLog.e(TAG, \"\" + new A().getI());\r\n\t}\r\n\r\n\t@Override\r\n\tprotected void onDestroy() {\r\n\t\tsuper.onDestroy();\r\n\t\tandroid.os.Process.killProcess(android.os.Process.myPid());\r\n\t}\r\n\r\n}\r\n\r\n```\r\n\r\n上面是正常的运行的，我没有做任何替换，也就是andFix还没有开始工作，没有执行方法替换操作。\r\n我修改了test()方法中的s变量值为\"xxxx\"，然后使用apkpatch工具生成out.apatch文件，并放置到SD卡，然后kill应用，测试方法被替换后的结果，但是出现了以下异常，应用闪退：\r\n10-30 15:00:48.059: E/dalvikvm(27735): threadid=1: unable to add 0x4163de40 to internal ref table\r\n10-30 15:00:48.059: W/dalvikvm(27735): ReferenceTable overflow (max=4096)\r\n\r\n将onCreate()方法中的for循环次数改为4000是正常的。\r\n**如果应用中被替换的方法出现在一个for循环中，而且循环次数比较多，那么这就是一个坑。**\r\n\r\n我测试的机型：MOTO G XT1032 ，系统：android 4.4.4 DVM。\r\n\r\n--EOF--\r\n"},"comment":{"url":"https://api.github.com/repos/alibaba/AndFix/issues/comments/248188659","html_url":"https://github.com/alibaba/AndFix/issues/103#issuecomment-248188659","issue_url":"https://api.github.com/repos/alibaba/AndFix/issues/103","id":248188659,"user":{"login":"landryshuai","id":1094226,"avatar_url":"https://avatars.githubusercontent.com/u/1094226?v=3","gravatar_id":"","url":"https://api.github.com/users/landryshuai","html_url":"https://github.com/landryshuai","followers_url":"https://api.github.com/users/landryshuai/followers","following_url":"https://api.github.com/users/landryshuai/following{/other_user}","gists_url":"https://api.github.com/users/landryshuai/gists{/gist_id}","starred_url":"https://api.github.com/users/landryshuai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/landryshuai/subscriptions","organizations_url":"https://api.github.com/users/landryshuai/orgs","repos_url":"https://api.github.com/users/landryshuai/repos","events_url":"https://api.github.com/users/landryshuai/events{/privacy}","received_events_url":"https://api.github.com/users/landryshuai/received_events","type":"User","site_admin":false},"created_at":"2016-09-20T02:59:15Z","updated_at":"2016-09-20T02:59:15Z","body":"@jacpy 我在最新版本测试了下你说的问题。没有发现同样问题。MI NOTE LTE Android：6.0.1"}}
{"actor":{"display_login":"landryshuai"}}