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.
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 aslr_save_stringandlr_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.