I am new to android development and I am trying to understand how this Garbage Collection
works but I need a clear explanation from someone first hand.
My app is doing some large transactions back and forth with a server. When I am switching from one activity to another, I constantly get the following message in my console:
GC_MINOR: (Nursery full) pause 2.77ms, total 2.95ms, bridge 11.82ms promoted 128K major 2640K los 4441K
and of course, the ms timing is different every time but it happens A LOT!
I read up on it here and created environment.txt file in my project with the following lines:
MONO_GC_PARAMS=nursery-size=1024m
MONO_GC_PARAMS=soft-heap-limit=64m
I was just testing different values at nursery-size
and soft-heap-limit
but it didn't help at all.
Right now, app runs REALLY slow when I go from one activity to another.
Can someone please explain in detail and present me with some options?
Thank you.
Garbage Collection works on different portions of heap
Which is different on different JVMs (Hotspot, IBM etc.) Generally Nursery size is lower than Tenured (Nursery << Tenured) Ex. In 2 GB of heap space Nusery can range from 128-512 and Remaining will be Tenured.
Nursery part will always be well managed by JVM. This part is used most of the time for new object creation, allocation as this part is lower in size GC operations (Compaction, GC collection)are fast and well tuned.
Tenured part is used when objects in Nursery grow in size or are alive for than a specific time limit (long living objects). They are maintained in Tenured. This is bigger chunk of memory and thus GC operations are slower.
Nursery pauses are generally small and shouldn't impact much when you are facing it continuously then that's sign of problem. While resizing nursery keep in mind that it should not be more than Tenured. Size is proportional to GC operations time.
In your case you should look at,
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.