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 do this, the app needs to store that data somewhere while working with it. The app allocates 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 can run out of it, making it impossible to continue its work. Even if the app doesn’t run out of memory, using too much can make the app slower, so faulty memory allocation can cause performance issues.

An app can run slower if it doesn’t optimize its allocation of data in the memory. If the app requires more memory than the system provides, the app will stop working and throw an error. Thus, side effects of poor memory management are slowness in execution and even total app crashes. It’s essential we write app capabilities that make the best use of their allocated memory.

If the app doesn’t allocate the data it processes in an optimized way, it may force the GC to run more often, so the app will become more CPU consumptive.

11.1 Sampling and profiling for memory issues

11.2 Using heap dumps to find memory leaks

11.2.1 Obtaining a heap dump

11.2.2 Reading a heap dump

11.2.3 Using the OQL console to query a heap dump

Summary