Skip to content

Memory Leaks in LoadRunner

A memory leak is memory that a program keeps allocating and never releases. Over time it slows the program down and finally crashes it. In LoadRunner projects, leaks show up in two places: in the application you are testing, and in your own scripts or load generators. This post covers how to tell them apart and how to prevent the second kind.

Two kinds of memory leaks in LoadRunner tests: application leaks on the server under test, and leaks in scripts or on the load generatorMemory leaks: on the server or in the script?Application leakserver memory after GCkeeps rising duringa steady load testScript / generator leakmmdrv or Vuser memoryon the load generatorkeeps rising
Check which machine is leaking before you report a defect.

Finding leaks in the application under test

  • Run a steady load for several hours (a soak test), not just a short ramp.
  • Monitor the server's memory, and for Java or .NET the heap after each garbage collection.
  • A level that keeps rising while the load stays flat suggests a leak. Response times often creep up at the same time.
  • Confirm with a heap dump or memory profiler before raising a defect.

Leaks in your own scripts

C-based scripts in VuGen can leak too, typically when custom code allocates memory and never frees it:

char *buf = (char *)malloc(1024);
/* ... use buf ... */
free(buf);   /* forget this and every iteration leaks 1 KB */
  • Free every malloc. Prefer LoadRunner's own functions such as lr_save_string and lr_eval_string, which manage memory for you.
  • Clean up parameters you no longer need with lr_free_parameter.
  • Avoid saving huge responses into parameters every iteration.

Leaks on the load generator

Watch the memory of the Vuser processes (for example mmdrv.exe) on each load generator during a long test. Steady growth means the generator, not the application, may become the bottleneck, and response times will be wrong. Running Vusers as threads, limiting logging, and spreading users over more generators help.

Frequently asked questions

Does extended logging cause memory growth?
It increases memory and disk use on the generator. Use it for debugging only, not in full load tests.

How long should a leak test run?
Long enough for growth to stand out from normal ups and downs. Many hours is common.

RG

Raviteja Gorentla

Performance engineer writing since 2010 about LoadRunner, JMeter, NeoLoad, APM tools and the real problems that show up in load tests. Every fix here was tested on a live project.

Page views