Skip to main content

How to find out Memory Leak in an application?

There are many reasons for memory leak and being a tester its tough to find exact reason. The basic thing we need to understand what is memory leak? How it occurs?
Memory leak can be defined as the un-allocated space in a system which was used by a program and after  use it was never returned to the operating system. This un-allocated (unused memory) can cause shortage of memory and may crash the entire system.

There are few steps which may help to find out memory leak in  a system:
  1. We can monitor the memory graph by using perfmon and check if the memory utilization is keep on increasing and remain at peak even without any load, it shows the memory that was used while executing the program is still in use even the program doesn't needs it. The un-managed code is not efficient enough to release the memory and free it after use, which may cause out of memory issue.
  2. You can check the throughput graph while load testing and if there is sudden spike in it then it can be one of the reason for memory leak. But we can't assure the spike in graph is because of memory leak, the other reason could be due to network traffic, data base connectivity issue etc.
  3. We have GC to collect all the un-allocated space and return it to system, it has some limitations:
  • In a manually managed memory environment: Memory is dynamically allocated and referenced by a pointer. The pointer is erased before the memory is freed. After the pointer is erased, the memory can no longer be accessed and therefore cannot be freed.
  • In a dynamically managed memory environment: Memory is disposed of but never collected, because a reference to the object is still active. Because a reference to the object is still active, the garbage collector never collects that memory. This can occur with a reference that is set by the system or the program.
  • In a dynamically managed memory environment: The garbage collector can collect and free the memory but never returns it to the operating system. This occurs when the garbage collector cannot move the objects that are still in use to one portion of the memory and free the rest.
  • In any memory environment: Poor memory management can result when many large objects are declared and never permitted to leave scope. As a result, memory is used and never freed.

Comments

  1. grate efforts keep it I rally like this posts

    Regards,
    kiran

    ReplyDelete
    Replies
    1. Thanks Kiran... I will continue to strive more and more..

      Delete

Post a Comment

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 pacing in a script: General Pacing:    1. As soon

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_EXIT_ACTION_AND_CONTINUE,LR_FAIL );                }

String Comparison in Loadrunner script

How to compare a string in Loadrunner script? -There are various methods to compare a string, in below example we have used "strcmp" to compare two values. We have captured a string in "pComparisonString" parameter and comparing it with ABC. Lets say if you have captured some string using correlation and want to compare if the captured string meets the condition then only pass the transactions else fail the transaction: if (strcmp(lr_eval_string("{pComparisonString}"),"ABC") == 0) { lr_output_message("The parameter value is %s", lr_eval_string("{pComparisonString}")); lr_end_transaction("Transaction_Failed",LR_FAIL); } else { lr_error_message("No parameter value captured."); lr_end_transaction("Transaction_Passed",LR_PASS); } -------------------------------------------------------- strcmp- String comparison function. pComparisonString- String which we have captured for compar