There are multiple ways to find the pair of numbers in a given array. The numbers in the array can be in two ways. SortedUnsorted
If the numbers are sorted then we can get easily with the complexity of O(n). The brute force approach will be easily applicable for both the sorted and unsorted array of numbers.
A heap dump is a snapshot of all the objects that are in memory in the JVM at a certain moment. They are very useful to troubleshoot memory-leak problems and optimize memory usage in Java applications.
Heap dumps are usually stored in binary format hprof files.
java.lang.OutOfMemoryError is thrown when there is insufficient space to allocate an
object. That is, garbage collection cannot make any further space available to accommodate a new object, and
the heap cannot be further expanded.
An OutOfMemoryError does not necessarily imply a memory leak. The issue might simply be a configuration issue, for example, if the specified heap size (or the default size if not
specified) is insufficient for the application.