I am using a custom GUI, and OpenTap 9.18.5.
In my current flow, upon completion of each instance of test, I will close the TestPlan. However, I encounter an issue where TestPlanRun is not getting release and memory usage just keep piling up the more test I ran, resulting in OutOfMemoryException. Would like some advice on expected behavior on this and how to tackle this as well.
Attached the screenshots from memory profiler, in this scenario I had ran 55 test.
Wanted to highlight that the Test Plan XML get converted to string and retained the most memory, also the OpenTap Diagnostic is taking quite some space as well.
See reply for other image.
Hi @vulcangui and welcome to the forum!
From what I can see in your screen shots it is not possible for me to identify which object is holding on to your TestPlanRun objects, causing them to not be garbage collected.
Are you sure that there is nothing in your UI holding on the the TestPlanRuns preventing them from being cleaned up?
If so, maybe you can develop a minimal example that reproduces the issue?
Hi @rolf_madsen,
@vulcangui and I are working together on this project! I created a simple application which is similar to the examples that are demonstrated in the OpenTAP SDK folder. And based on the profiling below
, we could see that the memory profiling kept increasing. From our investigation, it seemed like there is a memory leak caused by the PluginManager.SearchAsync call.
I have attached the code that we have used - but basically, it does a plugin search, loads and executes the test plan in a loop.
Here is the sample code:
Program.cs (1.5 KB)
Side note: there may be other places still causing the memory leak such as the App Test Plan Run mentioned by @vulcangui, but we can look at this simple application as a starting point.
Why do you need to call PluginManager.SearcyAsync all the time?
This should generally only be done once when you start the application or after a package has been installed.
Obviously it should also not leak memory, but generally speaking this is has not been a problem.