Android application becomes slow when using Android Studio Profiler
Asked Answered
S

0

7

What I try to do is get a lot of data about heroes in a game and save it in a DB, I use OkHttp to make request to the server and gson to parse the json and then save the classes I get from gson to the db by using an ORM from Jetbrains called Exposed.The calls are made in a loop, for each hero there will be 500 results about their last matches, there are 115 heroes, I let the thread sleep 1 sec before each request. The app starts running really fast, I can not even read the the results in the console, but after a while I get this:

I/zygote: Background concurrent copying GC freed 72775(3MB) AllocSpace objects, 5(5MB) LOS objects, 49% free, 5MB/11MB, paused 416us total 1.664s

and then the app runs really slow, I get 1 entry in the database/sec and at that point I expect to get another 15000. In the logcat I also get this

03-29 12:01:00.050 1634-1651/? W/android.os.Debug: failed to get memory consumption info: -1
03-29 12:01:00.059 1634-1651/? E/memtrack: Couldn't load memtrack module

the app does not crash, it just becomes extremely slow, The funny thing is that when I restart the app it is immediately slow, first time it got slow after 10 min, but then it is slow all the time. Also after I restart it writes things like

V/StudioProfiler: Loaded classes: 8137

Why would there be so many classes loaded if the app just started, what does this all mean I am a beginner and I really do not understand all this. Any ideas?

Thank you.

Spannew answered 29/3, 2018 at 12:22 Comment(6)
I am not sure, but I think it might have something to do with the Android profiler, cause I started the app a lot of times and then I restarted Android studio, did not look in the Android profiler and it was going pretty good, and then I took a look in the profiler and suddenly I get all this strange logs and the app is slow like a snailSpannew
Dinu Nicolae seems to be right, logs pop only after open Android profilerUniformitarian
My experience too. Whenever I switch to the tab showing Android Profiler in Android Studio, it just "destroys" everything. I have to reboot the dev PC and the phone.Granitite
I experienced exactly the same issue! The application (instrumented test) slowed down until it almost came to a halt, with garbage collection totals over 3 seconds. I tried emulators, real devices, ... nothing helped. Restarting android studio 3.1.2 and not opening the performance monitor solved the issue, everything is back to normal (gc total is +-100ms now instead of 3s)Tradesman
How did you got Exposed running on Android? I can't even create tables. Which driver do you use?Humidistat
Add this to your gradle repositories { maven { url "dl.bintray.com/kotlin/exposed" } } dependencies { compile 'org.jetbrains.exposed:exposed:0.10.1' compile 'com.h2database:h2:1.4.196' }Spannew

© 2022 - 2024 — McMap. All rights reserved.