Interview answers verified by specialists.
Find interview questions and answers on this website:
The steps that are required to check and avoid the context-related memory leaks are as follows: - Never keep the long-lived references linked with the context-activity. This reference can be of the same life as the activity or can be of different length that depends on the type of activity that is getting performed on the action. - Use of context-application is much better than the context-activity as it allows the application to be reused again and again and the activity can be viewed or executed only once. The application takes less time to execute and activity can take more due to consisting of more than one application in it. - Non-static inner classes should be avoided while getting used in the activity, as it doesn't control the life-cycle of the static-inner class and make some weak reference to the activities that are inside the process and getting used. - There should not be relying upon the garbage collector as it is not the ultimate solution for the memory leaks that are defined.