先上日志:
06-26 14:20:56.914 E/filemap ( 6485): mmap(258048,5040412) failed: Out of memory
06-26 14:20:56.914 W/asset ??( 6485): create map from entry failed
找到OOM的位置欢嘿。
罪魁禍?zhǔn)祝?/p>
Typeface tf = Typeface.createFromAsset(mgr, "fonts/ShouShuti.ttf");
每次文字加載都去獲取一下字體樣式瞧预,估計(jì)之后設(shè)置就沒(méi)有釋放
selectionPinPaint.setTypeface(tf);
導(dǎo)致OOM撰糠;
解決方式:
private static Typeface fontCache;
private static Typeface getFrontType(Context mContext) {
????if (fontCache ==null) {
????????try {
????????????????fontCache = Typeface.createFromAsset(mContext.getAssets(),"fonts/frontType.ttf");
? ? ? ????? }catch (Exception e) {
????????????????Log.e("TextUtil--line:584", "fonts/ZITI.ttf not found");
????????????????return null;
? ? ? ????? }????
????????}
? ? ? return fontCache;
}
增加緩存未檩。
selectionPinPaint.setTypeface(getFrontType(context));