Skip to main content

Why Memory Leaks Often Go Unnoticed Until Load Testing

Memory leaks can arise in various ways depending on how they are introduced, but they all exhibit a similar behavior, which ultimately makes them a performance issue.

To demonstrate, consider a simplified example involving a process. Imagine you're testing a function on a web server, where the process executes a computation and returns a result. During this, it requests a chunk of memory. However, due to a bug, the process mistakenly requests the same chunk twice. When the result is returned, it only releases one chunk, leaving the other unreleased.

Each time this function is called, the same issue occurs, and over time, the process consumes more of the host machine’s available memory, leading to a "memory leak." As this continues, the host system is impacted because the memory that should have been freed is never returned, causing the process to consume excessive resources until it either crashes or is forcefully terminated.

In my experience, these types of memory leaks are often uncovered during load testing. A function may return correct results and pass unit tests, which only evaluate a small number of cases. However, when this function is executed tens or hundreds of thousands of times, the memory issue becomes more evident, as it continuously reserves memory that is never released.

Identifying memory leaks is not always straightforward. There are valid scenarios where a process may reserve memory and not release it immediately. Unfortunately, it's not as simple as releasing every bit of memory as soon as it's used.


Although this is a simplified example, it reflects the typical pattern I associate with a memory leak: memory is allocated but not properly released, eventually leading to performance degradation.

Comments

Popular posts from this blog

Pacing Time in LoadRunner

What is Pacing? Where and why to use it? -Pacing is the time which will hold/pause the script before it goes to next iteration. i.e Once the   Action   iteration is completed the script will wait for the specific time(pacing time) before it starts the next one. It works between two actions. eg, if we record a script there will be three default actions generated by the Load Runner:   vuser_init, Action   and   vuser_end,   the pacing will work after the   Action   block and hold the script before it goes to repeat it. The default blocks generated by LoadRunner is shown below: Actions marked in Red Now we know what is pacing and we use it between two iteration. The next question comes to mind is why we use pacing: Pacing is used to: To control the number of TPS generated by an user. To control number of hits on a application under test.     Types of Pacing: There are three options to control the pac...

Error handling using Text Check

Error handling using if else condition. web_reg_find("Search=All",                      "Text/IC=Home Page",                      "SaveCount=home_count",                       LAST); //then after login block paste this code: if (atoi(lr_eval_string("{home_count}")) > 0)                 {                       lr_output_message("Log on Successful");                 }     else               {                     lr_output_message("Log on failed for the Login ID: %s", lr_eval_string("{pUserName}"));                     lr_exit( LR_E...

How to troubleshoot high Memory utilization during performance testing

 When troubleshooting high memory utilization during performance testing, it's important to identify the underlying causes and take appropriate steps to address the issue.  Here are some steps to troubleshoot high memory utilization: Monitor Memory Usage: Use performance monitoring tools to track memory usage over time. Monitor both physical and virtual memory (RAM) to identify if memory consumption is exceeding available resources. Identify Memory-Intensive Processes: Identify the specific processes or components that are consuming a significant amount of memory. Performance monitoring tools can help you identify the memory-hungry processes. Look for any particular application, service, or module that stands out in terms of memory usage. Analyze Code and Memory Allocation: Review your application's code and algorithms to identify any memory leaks, inefficient memory allocation, or excessive object creation. Look for areas where large amounts of memory are being consumed unnec...