我的设备上安装了53种字体。在此列表中从上到下滚动约20次会导致应用程序崩溃。使用循环视图时,我已添加将字体设置为null并手动调用System.gc(),结果相同。
列表适配器:
@Override
public View getView(int position, View convertView, ViewGroup parent) {
TextView textView;
//despite the gc, this function evenually causes out-of-memory
if (convertView != null && convertView instanceof TextView) {
textView = (TextView) convertView;
textView.setTypeface(null);
System.gc();
} else
textView = new TextView(context);
textView.setText(fontNames[position]);
textView.setTypeface(Typeface.createFromFile(fontPaths[position]));
textView.setTextSize(32);
return textView;
}
11-16 16:17:50.080 5402-5402/com.global.client A/libc: new failed to allocate 32768 bytes
11-16 16:17:50.080 5402-5402/com.global.client A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 5402 (al.mobileclient)
SDK 15和21,LGG2设备。还有什么我可以做的让这更有可能成功吗?