Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. Visual Studio Testing memory leaks? [modified]

Visual Studio Testing memory leaks? [modified]

Scheduled Pinned Locked Moved .NET (Core and Framework)
helpquestioncsharpvisual-studiotesting
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    springjazzy
    wrote on last edited by
    #1

    Hi ) Sorry for my English ( I hope you can help me with this: We created 1000+ tests in our solution. The problem is that they can't be run all in one batch - VSTestHost process simply dies with System.OutOfMemoryException. That's because it is 32 bit process and when it exceeds 2GB it dies. Ok.. Now the question is why is it happens? I've tried to profile testlist with 3-4 tests with JetBrains in order to find memory leaks. By the way - did anyone do such thing? I've created .bat-file with MsTest.exe. Then in [TestInitialize()] i've added MessageBox.Show("Start"); and began to make snapshots when this dialogbox appeared. The magic is that there are no memory leaks(+2000 bytes - almost no), but also there are no our classes. So, obviously, what I do to find memory leaks is wrong. I see that VSTestHost process eats a lot of memory with each passing test. Even 50 tests kills process with Memory exception. So did anyone encountered such problem? And how to profile VsTestHost on memory leaks? Maybe you can advise me where can I post this message to get an answer?

    modified on Tuesday, November 16, 2010 2:08 AM

    G 1 Reply Last reply
    0
    • S springjazzy

      Hi ) Sorry for my English ( I hope you can help me with this: We created 1000+ tests in our solution. The problem is that they can't be run all in one batch - VSTestHost process simply dies with System.OutOfMemoryException. That's because it is 32 bit process and when it exceeds 2GB it dies. Ok.. Now the question is why is it happens? I've tried to profile testlist with 3-4 tests with JetBrains in order to find memory leaks. By the way - did anyone do such thing? I've created .bat-file with MsTest.exe. Then in [TestInitialize()] i've added MessageBox.Show("Start"); and began to make snapshots when this dialogbox appeared. The magic is that there are no memory leaks(+2000 bytes - almost no), but also there are no our classes. So, obviously, what I do to find memory leaks is wrong. I see that VSTestHost process eats a lot of memory with each passing test. Even 50 tests kills process with Memory exception. So did anyone encountered such problem? And how to profile VsTestHost on memory leaks? Maybe you can advise me where can I post this message to get an answer?

      modified on Tuesday, November 16, 2010 2:08 AM

      G Offline
      G Offline
      GlobX
      wrote on last edited by
      #2

      As with all memory issues it could be a trillion different things (that's a scientific fact ;P ). I'm guessing it's got to do with your SetUp/TearDown process - can you post a small sample of your test harness code? I think the SetUp/TearDown for the whole harness, the per-test SetUp/TearDowns and also at least one test should be enough to figure something out. Is it the SUT that's causing this? Wild guess: static collections/instances that are constantly being added to by your tests and therefore the GC never disposes because the SUT still has references to it? I dunno, as I said, I think a little code may help your question get answered.

      S 1 Reply Last reply
      0
      • G GlobX

        As with all memory issues it could be a trillion different things (that's a scientific fact ;P ). I'm guessing it's got to do with your SetUp/TearDown process - can you post a small sample of your test harness code? I think the SetUp/TearDown for the whole harness, the per-test SetUp/TearDowns and also at least one test should be enough to figure something out. Is it the SUT that's causing this? Wild guess: static collections/instances that are constantly being added to by your tests and therefore the GC never disposes because the SUT still has references to it? I dunno, as I said, I think a little code may help your question get answered.

        S Offline
        S Offline
        springjazzy
        wrote on last edited by
        #3

        Sure. Here it is:

        [TestClass]
        public class SS_Identity_Types_Edit_Tests : TestsVS
        {
        SS_Identity_Types_FullEdit_Form view = null;

        \[TestInitialize\] public override void RunBeforeAllTests()
        {
        	base.RunBeforeAllTests();
                    view = new SS\_Identity\_Types\_FullEdit\_Form(this.basicWindow.DS);
                	PrepareEditForm(view, GetNamedContextOrCreate("SS\_Identity\_Types", false), false);
        	view.IsRunLoadActions = false;
        	view.Visible = true;
        	view.Visible = false;
        }
        
        \[TestMethod\] public void TestPrerequisites()
        {
        	Assert.IsNotNull(view);
        }
        
        \[TestCleanup\] public override void RunAfterAllTests()
        {
        	view.Close();
        	view = null;
        	base.RunAfterAllTests ();
        }
        

        }

        it inherits from sthm like this:

        \[TestInitialize()\]
        public virtual void RunBeforeAllTests() 
        {
        	basicWindow = DoCreateMainWindow();
                DoActionsOnLoad();
                basicWindow.LoadDataFromDataBase();
        }
        
            \[ClassCleanup\]
            public static void ClassCleanup()
            {
        // Here is commented bacause it really doesn't help
                //try
                //{
                //    System.GC.Collect();
                //}
                //catch
                //{
                //}
            }
        
            \[TestCleanup()\]
            public virtual void RunAfterAllTests()
            {
                InvokePrivateMethod(basicWindow, new object\[\] { new EventArgs() }, "OnClosed");
                this.basicWindow.Close();
                this.basicWindow = null;
            }
        

        I'm pretty sure there are leaks, but I can't get how to find them. As i've said JetBrains attached to test process doesn't show my classes, so, obviousely, I do sthm wrong in my profiling.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups