GUIDE / performance
How to Find Memory Leaks: QA Guide for Testers
Learn how to find memory leaks with symptoms, monitoring, soak tests, heap evidence, browser leaks, mobile checks, reports, and common mistakes.
How to find memory leaks is a practical QA skill because leaks often hide during short functional testing. A feature can pass every test case and still fail after hours of use because memory keeps growing, garbage collection becomes expensive, tabs slow down, mobile apps crash, or backend services restart under pressure.
This guide explains memory leak symptoms, test design, monitoring, soak testing, browser and backend examples, evidence collection, and bug reporting. The goal is not to turn every tester into a runtime expert. The goal is to help QA teams find credible leak signals and give developers enough evidence to diagnose the root cause.
How to Find Memory Leaks: The Short Workflow
Use this workflow:
- Pick a workflow that users repeat or keep open for a long time.
- Establish a clean baseline after startup.
- Repeat the workflow many times or run a long session.
- Monitor memory, CPU, garbage collection, and process restarts.
- Let the system idle or recover.
- Check whether memory returns near baseline.
- Capture charts, logs, heap evidence, and exact steps.
- Reproduce on a clean environment.
- Report impact and suspected pattern.
The key idea is trend. High memory is not automatically a leak. Some applications cache data intentionally. A leak is suspected when memory grows repeatedly and does not release after the workload ends or after reasonable garbage collection. Leaks surface most clearly under sustained load, so pair this work with stress and soak testing rather than short runs.
What a Memory Leak Looks Like
Memory leak symptoms vary by platform.
Backend symptoms:
- Memory usage rises steadily over hours.
- Garbage collection becomes more frequent or longer.
- Response time degrades over time.
- Process restarts or out of memory errors appear.
- Containers are killed by memory limits.
- Throughput drops during long runs.
Browser symptoms:
- Tab memory grows after repeated navigation.
- Single page app becomes slower over time.
- Browser crashes or reloads the page.
- Detached DOM nodes accumulate.
- Event listeners are not removed.
- Large objects remain after leaving a page.
Mobile symptoms:
- App becomes sluggish after repeated screens.
- Image heavy flows crash.
- Background and foreground cycles increase memory.
- Operating system kills the app.
QA testers usually do not identify the exact leaked object. They identify a repeatable pattern and provide evidence.
Memory Leak vs Normal Memory Growth
Not all growth is a leak. Applications cache data, warm up code paths, allocate buffers, and keep pools. A system may use more memory after startup and then stabilize.
| Pattern | Interpretation |
|---|---|
| Memory rises during work and returns near baseline | Usually healthy |
| Memory rises then stabilizes at a higher level | May be cache or warmup |
| Memory rises after every repeated cycle and never drops | Leak suspect |
| Memory rises until process restarts | Serious leak or memory pressure |
| Memory spikes during large operation then drops | May be normal allocation |
This is why leak testing needs repeated cycles and idle periods. A single snapshot is rarely enough.
Choose Leak Prone Workflows
Some areas are more likely to leak than others.
Good candidates:
- File upload and preview.
- Image editing or document viewing.
- Reports with large data.
- Real time dashboards.
- Chat or notification screens.
- Maps and charts.
- Repeated navigation in single page apps.
- Long running background jobs.
- Import and export flows.
- Video, audio, or canvas features.
Workflows with event listeners, streams, subscriptions, timers, caches, large objects, and third party widgets deserve attention.
Design a Repetition Test
A repetition test performs the same workflow many times and watches memory.
Example browser workflow:
1. Start a clean browser session.
2. Log in.
3. Open dashboard.
4. Open report page.
5. Apply date filter.
6. Export preview.
7. Return to dashboard.
8. Repeat steps 3 to 7 one hundred times.
9. Idle for five minutes.
10. Record memory trend.
Example backend workflow:
1. Start service and record baseline memory.
2. Send 10 requests per second to the report API for 30 minutes.
3. Stop traffic.
4. Wait 10 minutes.
5. Repeat the cycle three times.
6. Compare memory after each recovery period.
The recovery period matters. Some memory is released only after garbage collection or after asynchronous work completes.
Use Soak Testing for Leaks
Soak testing runs a realistic workload for a long duration. It is one of the best ways to find slow leaks.
Soak test signals:
- Memory trend rises throughout the run.
- p95 response time worsens over time.
- Garbage collection pauses increase.
- Error rate rises late in the test.
- Queue processing slows as memory pressure increases.
- The process restarts before the test ends.
For broader performance context, see how to do stress testing. Stress tests find breaking points. Soak tests reveal degradation over time.
Browser Memory Leak Testing
Frontend leaks are common in long lived web apps. Single page applications can keep components, listeners, timers, and objects alive after the user navigates away.
Browser leak checklist:
- Repeat navigation between heavy pages.
- Open and close modals repeatedly.
- Switch filters on charts.
- Upload and remove files.
- Start and stop live updates.
- Log out and log back in.
- Leave the app idle after activity.
Evidence to capture:
- Browser task manager memory trend.
- DevTools performance or memory profile.
- Heap snapshots if available.
- Steps and repetition count.
- Screenshots or recordings showing slowdown.
- Console errors.
Common frontend causes include unremoved event listeners, intervals, WebSocket subscriptions, cached large arrays, detached DOM nodes, and third party widgets that are not destroyed.
Mobile Memory Leak Testing
Mobile apps are sensitive to memory pressure because the operating system can kill apps that use too much memory or behave poorly in the background. QA should test repeated navigation, media heavy screens, offline caches, background and foreground transitions, and long sessions.
Mobile leak workflows:
- Open and close image heavy screens repeatedly.
- Scroll long lists with many thumbnails.
- Record, preview, and discard media.
- Switch between app and background many times.
- Rotate the device if supported.
- Open push notification deep links repeatedly.
- Navigate between tabs for an extended session.
Capture device model, OS version, app build, memory trend, crash logs, and the number of repetitions. A leak on a low memory Android device may not appear on a high end test phone during a short session.
For mobile apps, perceived impact matters. If memory grows and the app remains technically alive but scrolling becomes sluggish, that is still a user facing defect worth reporting.
Backend Memory Leak Testing
Backend leaks often appear under repeated requests or long running background jobs.
Backend leak checklist:
- Run a controlled load for a realistic duration.
- Monitor process memory, heap, garbage collection, and restarts.
- Track request latency over time.
- Watch queue consumers and scheduled jobs.
- Compare memory after traffic stops.
- Save logs around memory warnings or restarts.
Common backend causes include unbounded caches, static collections, connection leaks, stream handling errors, large response buffering, retained request objects, logging buffers, and libraries that keep references longer than expected.
QA should avoid guessing the exact cause in the defect title. Use evidence based language such as "Memory usage grows after repeated report export and does not recover after idle period."
Heap Dumps and Profiles for Testers
Developers may ask for heap dumps, allocation profiles, or memory snapshots. QA does not always need to analyze them deeply, but testers should understand how they fit into the investigation.
A heap dump is a snapshot of objects in memory at a point in time. A profile can show allocation behavior over a period. Browser memory snapshots can show detached nodes or retained objects. These artifacts help developers identify what is being retained.
QA can support the process by capturing snapshots at useful times:
| Time | Why It Helps |
|---|---|
| After startup baseline | Shows normal memory state |
| After repeated workflow | Shows growth after activity |
| After idle recovery | Shows what remains retained |
| After reproducing slowdown | Shows memory during user impact |
Do not attach large dumps casually to public tickets if they may contain sensitive data. Store them according to team policy and link securely. Mention the exact timestamp so developers can match dumps with logs and monitoring.
Narrowing the Suspect Workflow
Long soak tests are good for detection, but they may include too many actions to diagnose quickly. After detecting a leak, narrow the workflow.
Example narrowing path:
Initial signal:
Memory grows during 6 hour dashboard soak.
Narrow test 1:
Repeat dashboard open and close only.
Narrow test 2:
Repeat chart filter changes only.
Narrow test 3:
Repeat live notification panel open and close only.
Finding:
Memory growth appears only when live notification panel is opened and closed repeatedly.
This narrowing makes the defect much easier to fix. Developers can inspect event subscriptions, WebSocket cleanup, and retained notification objects instead of searching the entire dashboard.
When narrowing, change one variable at a time. Keep the build, browser, test data, and repetition count stable where possible.
What to Monitor
Use both system and application metrics.
| Metric | Why It Matters |
|---|---|
| Resident memory | Shows process memory footprint |
| Heap used | Shows managed runtime memory |
| Garbage collection count and duration | Reveals memory pressure |
| CPU | Leaks can increase GC CPU or processing cost |
| Response time | User impact often appears as slowdown |
| Error rate | Memory pressure can cause failures |
| Process restarts | Containers may be killed by memory limits |
| Object counts or heap classes | Helps developers locate retained objects |
If you do not have advanced profiling, still capture memory charts and steps. Developers can reproduce with profilers once QA shows the pattern.
Memory Leaks in CI and Long Running Environments
Some leaks appear only after many builds, scheduled jobs, or background tasks. CI environments, test servers, and staging services can reveal these problems if metrics are retained.
Watch for:
- Test service memory rises across pipeline runs.
- Browser automation workers consume more memory over the day.
- Staging API restarts at the same time every night.
- Background workers slow down after processing many jobs.
- Report generation works after deploy but fails after hours.
When automation infrastructure leaks, the product may be blamed incorrectly. For example, a flaky UI test suite might fail because browser workers are not cleaned up between tests. Include test infrastructure in the investigation when memory grows outside the application under test.
CI leak checks can be simple. Run a repeated workflow, record memory before and after, and fail only on a clear threshold after the pattern is stable. Avoid noisy gates until the measurement is trustworthy.
Separating Leak, Cache, and Load Problems
Memory growth can come from different causes.
| Pattern | Likely Direction |
|---|---|
| Growth stops at a stable level | Cache or warmup may be normal |
| Growth tracks active users but drops after logout | Session memory may be expected |
| Growth continues after repeated identical workflow | Leak suspect |
| Growth happens only during huge payloads | Capacity or streaming issue |
| Growth rises with queue backlog | Processing cannot keep up |
| Growth appears only in test runner | Automation infrastructure issue |
The tester's job is to describe the pattern accurately. Avoid forcing every memory issue into the word leak. A precise description gets better engineering attention.
Common Mistakes When Finding Memory Leaks
Mistake 1: Calling Any High Memory Usage a Leak
High memory may be normal cache behavior. Look for growth that does not stabilize or recover.
Mistake 2: Testing for Too Short a Time
Leaks often need repetition or duration. A five minute test may miss them.
Mistake 3: Skipping Baseline
Without baseline, you cannot tell whether memory changed meaningfully.
Mistake 4: Ignoring Idle Recovery
Always watch what happens after activity stops. Recovery behavior is important evidence.
Mistake 5: Mixing Too Many Workflows
If memory grows during a giant mixed test, isolating the cause is hard. Narrow the workflow after detection.
Mistake 6: Forgetting Browser Extensions and Local Noise
For browser tests, use a clean profile where possible. Extensions can distort memory behavior.
Mistake 7: Reporting Without Charts or Counts
Memory leak reports need trend evidence. Include numbers, duration, and repetition count.
Memory Leak Bug Report Template
Use this format:
| Field | Example |
|---|---|
| Title | Memory usage grows after repeated report export |
| Build | 2026.07.10 staging |
| Environment | Chrome clean profile, macOS, staging |
| Workflow | Open report, filter, preview export, return |
| Repetition | 100 cycles over 45 minutes |
| Baseline | Browser tab 420 MB after login |
| Actual | Tab grows to 1.8 GB and UI becomes sluggish |
| Recovery | After 10 minute idle, memory remains above 1.7 GB |
| Expected | Memory should stabilize or recover after leaving report page |
| Evidence | Memory chart, screenshots, console logs |
| Impact | Long lived analyst sessions may slow down or crash |
This report is actionable because it gives developers a path to reproduce and measure a fix.
Verifying a Memory Leak Fix
After developers fix a suspected leak, retest with the same workflow that exposed the problem. Keep the environment, build notes, data, browser or device, repetition count, and observation window as close as possible to the original test. If the original issue appeared after 100 cycles, a quick five cycle check is not enough evidence.
Fix verification should answer:
- Does memory still grow across repeated cycles?
- Does memory recover after the idle period?
- Did user facing slowdown disappear?
- Did logs stop showing memory warnings?
- Did the fix introduce new errors?
- Does the workflow still behave functionally?
Compare before and after charts when possible. A good result may not mean memory returns to the exact startup value. It may mean memory stabilizes at a healthy level and no longer climbs without bound. Capture that nuance in the Jira or bug tracker comment.
If the fix reduces growth but does not eliminate it, keep the ticket open or create a follow up depending on severity. For example, reducing tab growth from 1.8 GB to 700 MB may be acceptable for a short admin task but still risky for an all day dashboard.
Prevention Habits for QA Teams
QA can help prevent leaks by adding long session thinking to test design. Not every feature needs a formal soak test, but leak prone areas should get repeated workflow checks before release.
Useful habits:
- Include open and close cycles for modals, panels, and heavy pages.
- Retest long lived dashboards after major frontend changes.
- Watch memory during file preview, media, and chart work.
- Add soak testing to performance plans for services with queues or streams.
- Keep memory charts in release evidence for high risk features.
- Add regression checks for confirmed leak fixes.
Memory leaks are easier to prevent when teams treat cleanup as expected behavior. Components should unsubscribe. Streams should close. Temporary files should be released. Background jobs should not retain processed objects. QA can reinforce those expectations through targeted tests.
Final Checklist
Before reporting a memory leak, confirm:
- You started from a clean baseline.
- The workflow is repeatable.
- Memory grows across cycles.
- The app had time to recover.
- You captured duration and repetition count.
- You saved charts or snapshots.
- You checked user impact.
- You narrowed the workflow if possible.
- You documented environment and build.
- You avoided unsupported root cause claims.
Learning how to find memory leaks is about patience and evidence. Watch the trend, repeat the workflow, let the system recover, and report what changed. For practice, open QABattle and design a soak test for a dashboard, report, or upload flow. The exercise will make your performance testing sharper even before you use a profiler.
FAQ
Questions testers ask
What is a memory leak?
A memory leak happens when an application keeps memory it no longer needs. Over time, memory usage grows, garbage collection becomes heavier, performance degrades, and the process may slow down, crash, restart, or be killed by the operating system.
How can QA testers find memory leaks?
QA testers can find memory leaks by running repeated workflows or long soak tests, monitoring memory trends, comparing before and after usage, capturing logs and heap evidence, and reporting reproducible steps with environment and load details.
Are memory leaks only backend problems?
No. Memory leaks can happen in backend services, desktop apps, mobile apps, and browsers. Frontend leaks may come from event listeners, timers, detached DOM nodes, cached objects, or long lived single page app sessions.
What is the best test for memory leaks?
A soak test is often best because leaks need time or repetition to appear. Repeating the same workflow many times while monitoring memory can reveal whether usage returns to baseline or keeps growing after each cycle.
What evidence should a memory leak bug report include?
Include steps, build, environment, duration, memory chart, workload, expected recovery, actual growth, logs, screenshots, heap dump references if available, and whether the problem reproduces after restart or in a clean session.
RELATED GUIDES
Continue the route
How to Do Stress Testing: Complete QA Guide
Learn how to do stress testing with goals, workload models, tools, monitoring, stop conditions, failure analysis, reports, and QA examples safely.
Database Performance Testing: Complete QA Guide
Learn database performance testing with query checks, indexes, load data, monitoring, bottleneck analysis, reports, and practical QA examples.
Performance Testing Tools: JMeter vs k6 vs Gatling vs Locust
Compare performance testing tools in 2026: JMeter vs k6 vs Gatling vs Locust, open source load testing choices, and picks for APIs and microservices.
How to Read a Performance Test Report
Learn how to read a performance test report: interpret p95 and p99, error rates, throughput vs latency graphs, and find bottlenecks from load test results.