Cleanup substitutions / context

48 views
Skip to first unread message

David Perfors

unread,
Feb 17, 2012, 9:16:37 AM2/17/12
to NSubstitute
Hello,

I am looking into NSubstitute to possibly use it in our project
instead of Rhino.Mocks.
I really like the syntax of NSubstitute, but I was wondering how
NSubstitution uses the memory. I can see that all the mocks, calls,
etc are saved in the static SubstitutionContext.Current, and there
doesn't seem an easy way to clear the context.

Normally I wouldn't mind about mocks using some memory, but
unfortunately we already get OutOfMemoryExceptions in our tests. (I
know that part of our test suite is completely wrong, some of it I
just can't fix at the moment)

Should I worry about this for about 200 mocks or should it be better
to have the possibility to cleanup the current context?

Thanks in advance for the advice,
David Perfors

David Tchepak

unread,
Feb 17, 2012, 3:40:19 PM2/17/12
to nsubs...@googlegroups.com
Hi David,

Calls are saved on the substitutes themselves, so are cleared when
they go out of scope and are GCd.

We use NSub on a project with thousands of tests (and mocks) without
getting any out of memory exceptions, so anecdotally memory use seems
ok.

I guess one approach you could take is converting your heaviest
fixture to use NSub and see if that exacerbates the OOM exception
problem. If not you should be fine.

Regards,
Dave

> --
> You received this message because you are subscribed to the Google Groups "NSubstitute" group.
> To post to this group, send email to nsubs...@googlegroups.com.
> To unsubscribe from this group, send email to nsubstitute...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/nsubstitute?hl=en.
>

Reply all
Reply to author
Forward
0 new messages