Mobile Software Engineering I - Unit 6 Flashcards

(20 cards)

1
Q

What is the thread, given to each app’s process when initiated by the Android Runtime, called?

A

The main thread or UI thread.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What main categories of threads exist in Android?

A
  • attached to the life cycle of an activity
  • not attached to any activity
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How long, at a maximum, does the Android development team advise a call to take on the main thread?

A

15 ms

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What different states can a thread be in?

A
  • new
  • runnable
  • blocked/waiting
  • terminated
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What Java class and/or interface (fully qualified name) can be used what created a new thread?

A

java.lang.Thread or java.lang.Runnable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How can threads be terminated in Java?

A

Not directly, but through Thread.interrupt().

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What main reasons exist to use a message handler in java?

A
  • perform something in the future
  • perform something on another thread
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What methods can be used to schedule a message?

A
  • post(Runnable)
  • postDelayed(Runnable, long)
  • sendMessage(Message)
  • sendMessageAtTime(Message, long)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are the primary advantages of using a thread pool?

A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What Java class is used to manage a thread pool?

A

ThreadPoolExecutor

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Does Android attempt to use all available RAM, as little RAM as possible, or something in between?

A

All available RAM.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What main memory types are typically used in Android?

A
  • RAM: limited in size but fast
  • zRAM: a partition of RAM used for swap space
  • storage: the file system
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What tool does Android Studio provide to analyse memory allocations?

A

Memory Profiler

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the meaning of the following types of memory allocations:

  • allocations
  • native size
  • shallow size
  • retained size
A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What alternative to services can be used to reduce the risk of a memory leak?

A

IntentService

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is memory churn?

A

The rapid allocation of many temporary objects that cause a number of garbage collection events.

17
Q

What tools can be used to reduce the size of an APK file?

A

ProGuard and R8

18
Q

What type of exception is thrown if an application uses too much memory?

A

OutOfMemoryError

19
Q

What is the kswapd program, and what is it used for?

A

The kernal swap daemon is used to reduce the amount of used memory be converting used memory into free memory.

20
Q

What values can be passed to the onTrimMemory() method, and what do they mean?

A
  • 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