I'm getting an InflateException
preceded by an OutOfMemoryError
exception thrown. I understand that I should be able to solve the issue by either reducing the size/resolution of the image, or by adding android:largeHeap="true"
to my manifest, but something peculiar is happening.
This exception is not thrown when I first inflate the view. I have an Activity
that I'm using which contains a PreferenceFragment
. When you select a row in the PreferenceFragment
you are brought to a Fragment
which shows some images and text. The exception is only thrown after navigating back and forth between several of these fragments. It seems to me that something is not being properly disposed of since this will occur on any one of the fragments, but never occurs the first, second, or third time.
Is there a way I can ensure that everything is being disposed of when going back from one of these fragments?
Line where exception is thrown in OnCreateView
of Fragment
:
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
return inflater.Inflate(MyResource, container, false);
}
Also worth noting, exception is only thrown after several different fragments are opened from the activity. You could go back and forth between the same one all day and the exception would not be thrown.