Merge "Prevent a memory leak in TextLine." into ics-mr1

This commit is contained in:
Gilles Debunne
2011-12-12 15:53:25 -08:00
committed by Android (Google) Code Review

View File

@@ -102,6 +102,11 @@ class TextLine {
tl.mText = null;
tl.mPaint = null;
tl.mDirections = null;
tl.mMetricAffectingSpanSpanSet.recycle();
tl.mCharacterStyleSpanSet.recycle();
tl.mReplacementSpanSpanSet.recycle();
synchronized(sCached) {
for (int i = 0; i < sCached.length; ++i) {
if (sCached[i] == null) {
@@ -919,6 +924,12 @@ class TextLine {
}
return limit;
}
public void recycle() {
for (int i = 0; i < numberOfSpans; i++) {
spans[i] = null; // prevent a leak: no reference kept when TextLine is recycled
}
}
}
/**