I’m compiling a group of Android performance best practices, and one question came up about a common design pattern.
Imagine that you have an Android app that uses the following two distinct patterns:
Enum class:
public enum MyEnumSingleton {
INSTANCE;
...
}
Static class:
public final MyUtilsClass {
private Utils() {
//no instance
}
...
}
These two classes are used essentially with the same purpose: caching and utility methods.
In terms of memory usage:
- What is the most memory friendly pattern?
- Is the OS going to load all the enums into memory when the app starts?
- Is the OS only load the static class into memory when it is used by the app?
- Is there any use case were one pattern should strongly be used against another?
Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire