2
使用週期中,其中超過3000次迭代:約1000Android的境界:內存
for (Element e2 : elinks2) {
AllAuthors allauthor = new AllAuthors();
allauthor.setUrl_base(href.substring(0, href.length() - 1));
allauthor.setAuthor_fio(e2.text().trim());
allauthor.setLetters(e.attr("href"));
Realm realm_2 = null;
try {
realm_2 = Realm.getInstance(new File(func.getFolder("db")), getResources().getString(R.string.app_name_db) + ".realm");
realm_2.beginTransaction();
realm_2.copyToRealmOrUpdate(allauthor);
realm_2.commitTransaction();
} finally {
if(realm_2 != null) {
realm_2.close();
}
}
}
在添加(或更新)記錄一個錯誤就行
Out of memory in io_realm_internal_SharedGroup.cpp line 164
發誓
realm_2.commitTransaction();
有什麼建議嗎?
AllAuthors.class:
@RealmClass
public class AllAuthors extends RealmObject {
@PrimaryKey
private String url_base;
private String author_fio;
private String letters;
....Standard getters & setters generated....
}
奇怪的是,它的工作原理。謝謝! – SmallSani