in Education by
I am creating an application for Android. I am using Realm as a Database. Realm working fine in the whole app. Now I want to insert some data when from "NotificationExtender" class (This will help to receive and customise onesignal notification). Which leads to outOfMemory error How can I handle this. My sample code: In My Notification class I am doing this RealmLibrary.insertMessageToDBFromNotificationReceiver( jsonObject.getString("data"), jsonObject.getString("groupKey"), jsonObject.getString("groupKey"), mContext); And in my RealmLibrary class: Realm realm = getRealm(applicationContext); realm.beginTransaction(); ChatMessages chatmsg = realm.where(ChatMessages.class) .equalTo("gUid", gUID).findFirst(); int count = 0; if (chatmsg == null) { // Create an new object chatmsg = realm.createObject(ChatMessages.class); count = 1; chatmsg.setgUid(gUID); } else { } realm.commitTransaction(); Also my getRealm method: public static Realm getRealm(Context context) { return Realm.getDefaultInstance(); } How can i handle this outOf memory. Please anyone tell me which code leads to the error. Which is the not efficient code.. Note : it is just a sample code. If any details needed pls leave your comments. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
I currently have only 49 reputation points, so I can't comment this. Just an idea (maybe this is stupid, tell me if so and I'll delete this answer), you may want to add and use LeakCanary and check if you have some memory leaks: dependencies { debugCompile 'com.squareup.leakcanary:leakcanary-android:1.4-beta2' releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta2' testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta2' } and public class ExampleApplication extends Application { @Override public void onCreate() { super.onCreate(); LeakCanary.install(this); } } (use LeakCanary.install(getApplication()); if your Activity doesn't extends Application)

Related questions

0 votes
    I have an activity A that launches B with an Intent. (B is a MapActivity and has some async code ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 18, 2022 in Education by JackTerrance
0 votes
    I am seeking an Android solution to calculate the distance to an object and then determine the size (height ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 2, 2022 in Education by JackTerrance
0 votes
    I'm looking at making an custom Android object Serializable. Should be simple I just cannot find a easy ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Aug 1, 2022 in Education by JackTerrance
0 votes
    I've made a fresh eclipse reinstall + Android SDK v4.0. I am trying to create a new 4.0 AVD ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 30, 2022 in Education by JackTerrance
0 votes
    I'm trying to execute the following command: arp -a and I would like to redirect the output to a ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 26, 2022 in Education by JackTerrance
0 votes
    I've noticed on Marshmallow (e.g. Nexus 6P) and also on some more recently updated Lollipop phones ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    I'm trying to execute the following command: arp -a and I would like to redirect the output to a ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    i have this problem that i want to upload image on a server through multi-part form but its keep ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 8, 2022 in Education by JackTerrance
0 votes
    I want making multi-bluetooth from Android studio. I found multi-bluetooth java code libraries. but I am ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 3, 2022 in Education by JackTerrance
0 votes
    i want to run a task every 5 minutes. i've tried to solve it with an IntentService and ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 26, 2022 in Education by JackTerrance
0 votes
    i have this problem that i want to upload image on a server through multi-part form but its keep ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 19, 2022 in Education by JackTerrance
0 votes
    I want to put a settings icon to the right of a full-width button which when clicked opens an ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 4, 2022 in Education by JackTerrance
0 votes
    Animation example link: https://drive.google.com/open?id=1M5UBylFj0_8mtOEQT7jjsPN9DcCjyfPI I want to show my app ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    I just updated to Android Studio 3.4 (Canary 5). Then I opened my existing project (which worked ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 19, 2022 in Education by JackTerrance
0 votes
    How To Escape String Like Below. I Use Below Code But Say "The method unescape(String) is undefined ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 4, 2022 in Education by JackTerrance
...