Mobile Software Engineering I - Unit 6 Flashcards
(20 cards)
What is the thread, given to each app’s process when initiated by the Android Runtime, called?
The main thread or UI thread.
What main categories of threads exist in Android?
- attached to the life cycle of an activity
- not attached to any activity
How long, at a maximum, does the Android development team advise a call to take on the main thread?
15 ms
What different states can a thread be in?
- new
- runnable
- blocked/waiting
- terminated
What Java class and/or interface (fully qualified name) can be used what created a new thread?
java.lang.Thread
or java.lang.Runnable
How can threads be terminated in Java?
Not directly, but through Thread.interrupt()
.
What main reasons exist to use a message handler in java?
- perform something in the future
- perform something on another thread
What methods can be used to schedule a message?
post(Runnable)
postDelayed(Runnable, long)
sendMessage(Message)
sendMessageAtTime(Message, long)
What are the primary advantages of using a thread pool?
- improved performance when a large number of tasks are executed
- worker threads can be kept alive and reused
- life cycle of each thread is controlled by the thread pool overall life cycle
What Java class is used to manage a thread pool?
ThreadPoolExecutor
Does Android attempt to use all available RAM, as little RAM as possible, or something in between?
All available RAM.
What main memory types are typically used in Android?
- RAM: limited in size but fast
- zRAM: a partition of RAM used for swap space
- storage: the file system
What tool does Android Studio provide to analyse memory allocations?
Memory Profiler
What is the meaning of the following types of memory allocations:
- allocations
- native size
- shallow size
- retained size
- allocations: number of allocation in the heap
- native size: native memory used by the object
- shallow size: Java memory used
- retained size: total size of memory allocated
What alternative to services can be used to reduce the risk of a memory leak?
IntentService
What is memory churn?
The rapid allocation of many temporary objects that cause a number of garbage collection events.
What tools can be used to reduce the size of an APK file?
ProGuard and R8
What type of exception is thrown if an application uses too much memory?
OutOfMemoryError
What is the kswapd
program, and what is it used for?
The kernal swap daemon is used to reduce the amount of used memory be converting used memory into free memory.
What values can be passed to the onTrimMemory()
method, and what do they mean?
-
TRIM_MEMORY_RUNNING_MODERATE
: app is not under threat of being killed -
TRIM_MEMORY_RUNNING_LOW
: app is not under threat of being killed -
TRIM_MEMORY_RUNNING_CRITICAL
: the system will start killing apps -
TRIM_MEMORY_COMPLETE
: the app is next in line to be killed