1

Resharper Ultimate: 2016.3.2 DotMemory: 2016.3.2 Visual studio 2017 Windows 7 Prism 6.3.0 Ninject

This is a bit of a strange one, so I'm not sure exactly how to describe it, but i'll give it a shot.

Originally, I had pages set up to register with their regions, so all my pages were declared as follows

_kernel.Bind<IPageView, PageView>().To<PageView>();

followed by binding them to the region.

_regionManager.RegisterViewWithRegion(RegionNames.ContentRegion, typeof(PageView));

While updating things, I decided rather than having the hassle of binding the pages, and registering them with the region, I'd switch to using RequestNavigate, so I removed registering the view with the region, and changed the binding to

_kernel.RegisterTypeForNavigation<PageView>( PageNames.MyPage);

In debug mode this all worked perfectly fine. However this is where things get odd. I ran dotmemory to do some leak testing and found that if I took a snapshot before entering certain pages, the software would crash. If i didn't take a snapshot, or I took a snapshot after entering the page, nothing crashes.

Additionally, if I add

_kernel.get<PageView>();

after binding the page, I also have no issues. (so right now this is my terrible temp fix)

I'm just wondering if anyone has any idea why this might be happening. The only two conclusions I've come up with are either

a) RequestNavigate isn't resolving through ninject correctly. b) Somehow getting the snapshot from dotmemory is clearing anything that hasn't already been resolved from the kernel.

I'm not expecting much, but if anyone has any ideas what may be causing this it'd help a fair bit.

user3265613
  • 355
  • 2
  • 14
  • Getting snapshot in dotMemory causes full garbage collection. Try to call GC.Collect(4) at a place when you usually get a snapshot and check is it a reason of the crash – Ed Pavlov Apr 28 '17 at 12:19
  • Just popped GC.Collect(4) in a couple places just in case. Doesn't cause the crash to happen. Also tried with GC.Collect() and a few other combinations. – user3265613 Apr 28 '17 at 13:15
  • Please gather dotMemory core logs as described [here](https://dotnettools-support.jetbrains.com/hc/en-us/articles/207242575-How-to-get-dotMemory-Core-logs-) and send them to dotMemory [issue tracker](https://youtrack.jetbrains.com/issues/DMRY) or [JetBrains support service](https://dotnettools-support.jetbrains.com/hc/en-us/requests/new) – Ed Pavlov Apr 28 '17 at 13:58
  • After playing around more, it looks like something is going wrong with the parameter I'm trying to pass in. TypeLoadException: GenericArguments[0], 'System.Double', on 'Castle.Proxies.Invocations.IValueParameterFactory_CreateValueParameter[TViewModel]' violates the constraint of type parameter 'TViewModel'. Still trying to decipher what the heck the errors talking about mind you, never was good with generics. – user3265613 Apr 28 '17 at 14:52
  • My best guess at the moment is that dotmemory is clearing up memory used by Ninject during its GC before the snapshot. Seems like the automagical binding stuff I don't understand is what's going wrong. (the ninject auto factory stuff seems the most likely culprit) I've submitted the support request to jetbrains. For now I'll just have to avoid doing a snapshot on pages with those parameters. – user3265613 Apr 28 '17 at 15:35
  • The issue looks like it's actually with the Ninject.AutoFactory stuff. Our parameters are created with a generic factory, and it seems there are a few issues raised on this topic on Ninjects issues tracker. I imagine we're very lucky in the fact it works in the first place, and ninject is clearing up whatever is making it work. – user3265613 Sep 21 '17 at 09:44

0 Answers0