Heap profiling (Memory Profiling) enables you to understand the memory allocation and garbage collection behavior of your applications over time. Memory profiling helps in identifying method calls in the context within which most memory was allocated and combine this information with the number of allocated objects. The survivor respective helps you to understand the context within which your long-living objects (Objects that survive multiple garbage collection cycles are created). In memory profiling window, you can see the following details which are listed below:

- Session Details
- Memory Profiling Session
- New Memory Allocation
- Memory Leaks

## Pre-requisite

For memory functionality to work correctly, the application must include the native agent argument. Ensure the following argument is added to the application startup configuration: -agentpath:/home/cavisson/netdiagnostics/lib/libjavanativeagent.so=feature_all.

## Add New Session

To add new memory profiling session, you have to click on the Add New Session icon on the top left corner of the window. Once you click on the add new session icon, the Configuration Topology Window will open where you have to provide the topology details by selecting the tier, server and instances.

## Memory Profiling Session

In memory profiling session, you can see the details for the sessions which are related to a particular memory profile. In memory profiling session, you can see the following details related to the session which are listed below:

- Name: This shows the session name.
- Tier: This shows the tier name.
- Start Time: This will show the start time for the test.
- Duration: This will show the total duration of the test run.
- Description: This will show the session description.
- Session Details: This will show the details for the session such as: Session Name, Tier Name, Server Name and Instance Name.

Note: You can also delete an existing memory profiling session by clicking on the Delete icon.

## New Memory Allocation

In new memory allocation, you can see a list of classes which have been allocated with new memory. In new memory allocation, you can see the details for the following which are listed below:

- Class Data
- Statistics

## Class Data

In class data, you can see the new memory allocated details in tabular format. There are following fields which are listed below:

- Class: This shows the name of the java class used.
- Total Objects Created: This shows the total number of objects created for a particular class.
- Creation Rate/Min: This shows the number of objects which have been created in 1 minute.
- Average Object Size (KB): This shows the average size of an object which is being created in KB.
- Total Allocation (MB): This will show the total memory which is being allocated to the class in MB.

### Stack Trace

A stack trace will capture the total stack trace during the session. The default value for stack trace is 1000, default minimum value for stack trace is 100 and default maximum value for stack trace is 10000. In stack trace window, you can see the following details which are listed below:

- Stack Trace: In this, you can see the full stack trace for the selected class.
- Count: In this, you can see the count for the total created objects.

### Statistics

In statistics, you can see the new memory allocated details in graphical format. There are following fields which are listed below:

- Heap Max Size: It is the maximum size allocated to the heap memory.
- Used Heap Before: It is the size of heap before the allocation of the memory.
- Used Heap After: It is the size of heap after the allocation of the memory.
- Free Heap Before: It is the amount of memory that is currently unallocated and available for new objects to be allocated.
- Free Heap After: It is the amount of heap that is remaining after the memory allocation is successfully fulfilled.

In statistics, you can see three different types of statistical data in pie or chart format which are listed below:

- Total Allocation
- Total Objects Created
- Single Object Size

## Memory Leaks

Memory leaks are programming errors where the allocated memory is not properly deallocated or release when it is no longer needed, as a result the memory which is no longer in use remains allocated. In memory leaks window, you can see the following details which are listed below:

- Class Data
- Statistics

### Class Data

In class data, you can see the new memory allocated details in tabular format. There are following fields which are listed below:

- Class: This shows the name of the java class used.
- Survived Memory (in KB): This refers to the portion of the memory that is still in use or actively being referenced by a program after a garbage collection process.
- Survived Object Count: This refers to an object that are still in use or active after a garbage collection process. In survived object count you can see the total number of the objects which survived after the memory leak.

### Stack Trace

A stack trace will capture the total stack trace during the session. The default value for stack trace is 1000, default minimum value for stack trace is 100 and default maximum value for stack trace is 10000. In stack trace window, you can see the following details which are listed below:

- Stack Trace: In this, you can see the full stack trace for the selected class.
- Count: In this, you can see the count for the total created objects.

### Statistics

In statistics, you can see the new memory allocated details in graphical format. There are following fields which are listed below:

In statistics, you can see the new memory allocated details in graphical format. There are following fields which are listed below:

- Heap Max Size: It is the maximum size allocated to the heap memory.
- Used Heap Before: It is the size of heap before the allocation of the memory.
- Used Heap After: It is the size of heap after the allocation of the memory.
- Free Heap Before: It is the amount of memory that is currently unallocated and available for new objects to be allocated.
- Free Heap After: It is the amount of heap that is remaining after the memory allocation is successfully fulfilled.

In statistics, you can see the data in the following two graphical formats which are listed below:

- Pie
- Chart

You can also see two different types of statistical data in the pie or chart format which you can see in the total allocation which are listed below:

- Survived Memory
- Survived Object Count

#### Notes:

- You can also perform some additional actions in the statistics window by clicking on the Chart Context Menu
- Once you click on the chart context menu, you can see the following options in the drop-down which are listed below:
  1. View in Full Screen: By selecting this option, you can view the statistical data in full screen.
  2. Print Chart: By selecting this option, you can print the chart.
  3. Download PNG Image: By selecting this option, you can download the image in .png
  4. Download JPEG Image: By selecting this option, you can download the image in .jpeg
  5. Download PDF Document: By selecting this option, you can download the image in .pdf
  6. Download SVG Vector Image: By selecting this option, you can download the image in Scalable Vector Graphics format which is an XML-based vector format.
- You can also perform the following operations in the stack trace window which are listed below:
  1. You can copy the stack trace. To perform this operation, you have to click on the Copy
  2. You can also search a stack trace by the name of the stack trace in the Search
- Files for Memory Profiling Session are present at path:

  `<NS_WDIR>/ndc/serverlogs/memory_profiler`