11 Finding memory-related issues in an app’s execution
This chapter covers
- Sampling an execution to find memory allocation issues
- Profiling a part of the code to identify the root causes of memory allocation problems
- Obtaining and reading heap dumps
Every app processes data, and to process the data, the app needs to store that data somewhere while working with it. The app allocates a part of the system’s memory to work with the data, but the memory isn’t an infinite resource. All the apps running on a system share a finite amount of memory space that the system provides. If an app doesn’t wisely manage its allocated memory, it might run out of memory, making it impossible to continue its work. Even if the app doesn’t run out of memory, using too much of it might make the app slower – so faulty memory allocation can be a cause of performance issues.
An app can run slower just because it doesn't allocate data in the memory in an optimized way. If the app allocates more memory than the system provides, the app will stop working and throw an error. It's essential we write app capabilities that use their allocated memory in an optimized way.