Re: OutOfMemory Exception

<[email protected]>
Newsgroups gmane.comp.windows.dotnet.nunit.user
Message-ID <E961123C01E7E94AA29163941172913E040FC06B@mail1.dundee.realtimeworlds.com>
Further investigation leads to interesting results.

 

If you take the allocate and deallocate code out of the test fixture
then the tests run fine!

 

So the test fixture setup and teardown would contain no AllocHGlobal or
FreeHGlobal, this seems to fix the InsufficientMemory Exception that we
were getting but we're no closer to figuring out why.  Maybe a memory
leak in the text fixture setup?  This seems unlikely though but the
pattern of failures do indicate a memory problem.  I just can't see how
it can be our code as of yet.

 

I'll keep you updated with anything we find.

 

 

From: [email protected]
[mailto:[email protected]] On Behalf Of
[email protected]
Sent: 31 October 2007 14:10
To: [email protected]
Subject: [Nunit-users] OutOfMemory Exception

 

Hi all,

 

Glad to be part of the Nunit community, it's an essential development
tool as far as I'm concerned.

 

I have found an issue with a set of NUnit tests that we are running at
the moment that we are getting OutOfMemoryExceptions hapenning when the
tests are run repeatedly in the Nunit GUI (without closing the Nunit
window).  

 

The code in question does Allocate and Free memory but the tests always
pass the first time they are run.

 

We made a smaller project that just does the memory allocation and the
same thing happens although it requires more repeated runs of the unit
tests.  I searched the bugs and the previous posts on this mailing list
and I couldn't find anything so I don't know if its our code or
something about Nunit that maybe we don't understand.

 

The basic test we wrote to catch the issue looks like this

 

        [Test]

        public void ReAllocateAndFreeMem()

        {

            int x = 0;

            while (x < 100)

            {

                m_ptr =
(IntPtr)Marshal.AllocHGlobal((Marshal.UnsafeAddrOfPinnedArrayElement(m_a
rray, 0)));

                Marshal.FreeHGlobal((IntPtr)m_ptr);

                x++;

            }

        }

 

And we have a setup and teardown on the fixture like this

 

        [TestFixtureSetUp]

        public void Create()

        {

            m_ptr =
(IntPtr)Marshal.AllocHGlobal((Marshal.UnsafeAddrOfPinnedArrayElement(m_a
rray, 0)));

        }

 

        [TestFixtureTearDown]

        public void Quit()

        {

           Marshal.FreeHGlobal((IntPtr)m_ptr);

        }

 

Any thoughts?

 

Robbie


DISCLAIMER
This message and any attachments contain privileged and confidential
information intended for the use of the addressee named above. If you
are not the intended recipient of this message, you are hereby notified
that any use, dissemination, distribution or reproduction of this
message is prohibited. Please note that we cannot guarantee that this
message or any attachment is virus free or that it has not been
intercepted and amended. The views of the author may not necessarily
reflect those of Real Time Worlds Ltd.
____________________________________________________________________
This email has been scanned by the MessageLabs Email Security System

____________________________________________________________________
This email has been scanned by the MessageLabs Email Security System


DISCLAIMER
This message and any attachments contain privileged and confidential information intended for the use of the addressee named above. If you are not the intended recipient of this message, you are hereby notified that any use, dissemination, distribution or reproduction of this message is prohibited. Please note that we cannot guarantee that this message or any attachment is virus free or that it has not been intercepted and amended. The views of the author may not necessarily reflect those of Real Time Worlds Ltd.
____________________________________________________________________
This email has been scanned by the MessageLabs Email Security System

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/

_______________________________________________
Nunit-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nunit-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.