android - How to use RealmBaseAdapter without memory exceptions? -


i trying figure out right way use realmbaseadapter.

background:

  • i have app single activity , many fragments.
  • the main screen fragment contains viewpager child fragments (with tabs in action bar).
  • each child fragment contains list view displays realm results using subclass of realmbaseadapter.
  • when user taps on item in 1 of list views inner fragment displayed (it replaces main fragment child fragments).
  • for realmbaseadapter work realm object created realmresults has open (after getinstance , before close), have base fragment creates instance of realm in onstart , closes in ondestroy.

now problem:
there re many memory related crashes in app , think understand reason.
problem there @ least 1 open realm, avoids cleaned.
meaning realm grows in memory time , never gets chance cleaned.

according few memory related issues in realm's github repo understand realm should opened , closed short operation possible, comes in contrast fact realmbaseadapter requires originating realm object open life time.

any help/thoughts appreciated.

in faq @ https://realm.io/docs/java/0.80.0/#faq explains why file size of realm might increase (see section "large realm file size").

i recommend compact realm file when app either starts or resumes (and before opens realm instance). method realm.compactrealmfile() method should looking (see https://realm.io/docs/java/0.80.0/api/io/realm/realm.html#compactrealmfile-android.content.context-).


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -