Now the problem is that launching the test suite by any other mean does not start the profiler, ie MemProfiler.IsProfiling = false. Basically, what i was trying to do is write a test for every memory leak i found in my application to prevent regression. These tests are not run interactively, but rather by my build process under nAnt using a nUnit task (this build my code and run all my tests for me, reporting errors).
Another way of running the test is with TestDriven.Net, a free add-in for visual studio that let you run your nunit test directly in the ide. Again, i haven't find a way to start the profiler prior the beginning of the test.
At first, i was thinking that i should instanciate the profiler class and call Start but there is no such methods. So, i just want to use the profiler by code without any UI to test that my object are no more in memory. Is it possible ?
If you want to perform automated testing, it is possible to start NUnit under the profiler using command line arguments. The profiler can be run in a non-interactive mode by using the command line argument /noui.
Note that it is also recommended that you disable root referee identification if your run NUnit under .NET Framework 1.x. The command line below shows an example on how you can start NUnit under the profiler.
NetMemProfiler.exe /ri- nunit-gui.exe [optional arguments to NUnit]
For more information about the command line arguments, see the "Starting .NET Memory Profiler" section in the documentation.
SciTech Software AB
Is there a plan to add Attaching to process fonctionnality to a next release?
One thing that makes it harder to perform memory testing using .NET Memory Profiler and NAnt, is that the NUnit task is integrated with NAnt. As mentioned previously, in order to perform memory assertions, it is necessary to start the profiled application using .NET Memory Profiler. In this case I see two options:
- Start the whole build process using .NET Memory Profiler. E.g.
<path to MemProfiler>\NetMemProfilerConsole.exe /ri- NAnt.exe
- Avoiding using the <nunit2> task and start an external NUNit session. This can be performed using the exec task. E.g.
Code: Select all
<exec program="NetMemProfilerConsole.exe"> <arg value="/ri- NUnit.exe" /> <arg value="TestAssembly.dll" /> </exec>
In order to make the build process fully automated, it is recommended that you provide command line arguments that defines what to do when a memory assertion fails (e.g /memleakprompt, /memleakcollect), and what to do when the session ends (e.g. /sessionprompt).
The next version of the profiler will allow you to attach to a process, but the snapshot information obtained will be less detailed (e.g. no stack trace will be presented).
SciTech Software AB
Users browsing this forum: No registered users and 18 guests