My app doesn't contain any native code but I am using the following libraries :
Fireabse auth
,database
,storage
,messaging
Google Maps
, Location
SendGrid
- for sending emails
RazorPay
Glide
When my app starts, the RAM taken by Native section is around 180 MB and after I open a fragment which reads data from the real-time database a couple of times, the RAM usage by Native section shoots up to 800 MB!
How can I reduce this?
Edit:
My dependencies
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.firebase:firebase-auth:16.1.0'
implementation 'com.google.firebase:firebase-database:16.0.6'
implementation 'com.google.firebase:firebase-storage:16.0.4'
implementation 'com.google.firebase:firebase-messaging:17.3.4'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.android.gms:play-services-auth:16.0.1'
implementation 'com.google.android.gms:play-services-maps:16.1.0'
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.payumoney.sdkui:plug-n-play:1.5.0'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.razorpay:checkout:1.4.5'
implementation files('libs/sendgrid-0.1.2-jar.jar')
implementation 'com.github.bumptech.glide:glide:4.9.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.github.mklimek:frame-video-view:1.3.3'
Here's how I query data from the database
DatabaseReference carReference = FirebaseDatabase.getInstance().getReference();
carReference.child("carDetails").addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
ArrayList<String> carsOwnedByUser = new ArrayList<>();
for (DataSnapshot carDetails : dataSnapshot.getChildren()) {
CarDetails car = carDetails.getValue(CarDetails.class);
if (userId.equals(car.getUserId())) {
carsOwnedByUser.add(car.getMake());
}
}
String selectedCar = sharedPreferences.getString(Constants.SHARED_PREFERENCES_SELECTED_CAR, "None");
if (carsOwnedByUser.size() > 0) {
if (selectedCar.equals("None")) {
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString(Constants.SHARED_PREFERENCES_SELECTED_CAR, carsOwnedByUser.get(0));
editor.apply();
}
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
What I have tried:
I have tried disabling the disk Caching in Glide and I have tried setting the DatabaseReferenec.getInstance().setPersistacneEnabled() and keepSynced() to false but they didn't help.
Edit 2:
I checked the heap dump in the profiler and saw that Bitmap was taking 300 MB in the native section