Have developed application with ExoPlayer. Which works fine for shorter period. After few hours of continuous playback, app freezes. Not even the back button. Don't see any logs after the freeze in the logcat of androidStudio.
I used android profiler to check with the memory. I can see native memory is increasing. The app size is 45MB. Native memory increased from 120MB to 390MB. I don't know where does this memory is keep on adding.
There is only one activity and a fragment is there in my app. Live content will be playing on start.
Don't know how to fix this. Not even the logs are helping. Sometimes app crashes. But I don't see any logs.
Related
I just try to understand the reason of it. Our app is really stable and optimized, but time to time it just switch off during the work on foreground mode. User is using it, and it' just closed without any crash or ANR messages - really bad experience. What we already did:
use UncaughtExceptionHandler and print logs to the disk for analyzing. Logs are empty, not information about crashes for these cases
used Firebase crashlityc - is empty too
checked app with help profiler and leakcanary - no leak, memory using ~200 Mb
A bit words about our app:
clear arhitecture, Kotlin, MVVM, coroutines, dagger, retrofit, room, one single activity app
app should work all time, infinitely. App is an interface for hardware terminal.
the most part of fragments are stored into the backstack and reused again, it help to make screen opening faster after first fragment using. No leak with it, no fragment or viewModels duplicates
we use glide for downloading and previewing user avatars. I'm afraid, that leaks could be a part of bitmaps or jpg. Profiler doesn't show it after 1-2 hours tests, but I didn't test it during for ex. one week
possible app interruptions happen more often, when device is uncharged or just started (first 10-20 minutes after device start)
the most part of clients has a bad WIFI connections
we have ~10 modules, the most part of them are own canvas libs
crashes happen in random moments...
we also have ANR problem for some clients, but we added ANR watchdog, so soon we will know the reason of it.
we have 50-60 singletons. I'm not sure, that is bad or good. The first plan was using much memory to make app faster.
For me it looks like a native crash or system kill, but how to repeat it? I still don't understand the real reason of it. If you faced with similar problem, please describe your experience, it could be helpful for us. Thx!
After playing my libgdx-game for some time, it just freezes. the game loop is not being executed anymore and it does not react to any input; the game can just be killed.
Logcat says this:
The memory graph shows:
(The freeze starts at about 8m30s. Before this time the game is running normally.)
The question: What is happing here? What do I have to do to avoid this game crash?
Could you post more logcat? It's hard do gather any information as to what is causing the problem just by looking at it saying it's suspending all threads.
This usually happens when you run out of memory. Do you have peices of code which load stuff into memory? You may want to take a look at that. Just a possibility, but maybe you are running out of memory. I know what the memory graph shows, but I had a similar problem and I fixed it by optimizing some asset loading.
(you may want to use asset manager to handle memory optimization)
https://github.com/libgdx/libgdx/wiki/Managing-your-assets
If that is not the case, please post some code. (or more logcat)
I have an app that is doing a lot of work related to Bluetooth connection and displaying graphs etc.
App is using many libraries as well. App has also a background service running all the time. Now I noticed that it is taking upto 500 Mbs of Memory Usage.
What I have done was commented out. Everything on app launch and just showed splash screen (custom made) and still footprints are 60-70 Mbs. That means something is taking too much memory without even using it.
One important thing is that Android Studio's Memory Monitor is showing me that app is using only 40-50 Mbs whereas my phone's Memory manager is showing upto 500 MBs. I have tested this on 3 phones. Result remains same.
Any help should be appreciable.
You are leaking alot of memory you can go to memory monitor in android studio and use garbage collector to have an estimation of the total amount of leak you're having.
Most of the time External libraries are main Issue for the memory leakage due to their differing implementations and are quite inefficient when used for work on mobile client.
Here is a great blog regarding memory leakage.
http://blog.nimbledroid.com/2016/05/23/memory-leaks.html
Use MAT Tool to find out memory leakage and resolve that.
Once started service, if it is no needed then stop the service using intent.
And also check you have started any timer thread and not stopped it.
I am actually experiencing a heap problem while using interstitials (2.3 Nexus One).
I am able to reproduce the problem using the admob sample from Google play (android sdk). I have just set my ad id and my device id as a test device (I also have the problem without doing setting the test device id).
Just launch the sample, choose interstitial, Load, Display, Close.
Now in DDMS you can see a given amount of Allocated memory after having triggered the GC. (in my case 3.421 MB)
Then if I keep on repeating the Load, Display, Close operation, I see that the Allocated size on the heap just keeps on increasing. After some launches I reach 3.936 MB, and it never seems to stop.
I DO NOT change the phone orientation in between or do anything fancy.
I have tried changing new InterstitialAd(this) to new InterstitialAd(getApplicationContext()) as suggested in some other questions, but it does not change the problem.
On a 4.4.2 emulator the problem seems to exist too (I say seem because as the emulator is really slow it is hard to perform the operation a big number of times).
Of course I have the same problem with my real application. In my real app I also tried recreating the interstital before each loading (after having removed its listener) but the problem is exactly the same, so my guess is that it is not the interstitial instance itself that leaks, but perhaps the web view, or one of admob threads.
In my real application this causes a crash when loading a "big" bitmap (a 800*560 png) because of a OutOfMemoryError failed to allocate... so I am afraid that this may also leak some native memory (which is used for bitmap allocation in 2.3)
EDIT : It seems to leak some native memory indeed, but a very samll quantity.
On my app I have a webview that loads a webpage which contains an online broadcast. The problem is that once I exit the app it seems to keep getting data since my free memory continues to decrease. It comes back to normal only if I close the app manually.
I have found this topic here as well:
How do I pause Flash content in an Android WebView when my activity isn't visible?
I also had the problem described there: my flash content kept working even if the app wasn't on the screen (I could hear it). Now it's fixed with the code shown there, but as I said, it keeps draining memory anyway.