Fody PropertyChanged Weaver Causes Memory Issues

506 views Asked by At

I installed PropertyChanged.Fody into a WPF application. Now 3rd party code that uses native memory are having memory allocation issues. Uninstalling PropertyChanged.Fody resolves all these issues. I thought that the package was causing property changed injection into classes in those assemblies so I added a [assembly: PropertyChanged.FilterType("My.Specific.OptIn.Namespace.")] the project I installed fody in to make injection opt-in. Note that I left the filter attribute exactly as I just wrote it so that nothing at all matches, just to test. Still having issues however.

1

There are 1 answers

0
Sheldon Cooper On

After days of debugging I've finally found the issue. My project is set to ANYCPU and Prefer 32 which by default allows it to access more RAM. Fody does not respect this and leads to a normal 32bit assembly that can only access 2GB of RAM.

Before (ANYCPU + Prefer 32): enter image description here

After (with Fody): enter image description here

My solution was to use the Large Address Aware NuGet package (the target in the package only runs if you change your Platform Target to x86, in my case I changed from ANYCPU + Prefer32 to simply x86). I configured my .csproj to look like this:

 <PropertyGroup>
   <LargeAddressAware>true</LargeAddressAware>
   <LargeAddressAwareAfterTargets>FodyTarget</LargeAddressAwareAfterTargets>
 </PropertyGroup>

I've alerted the contributers of PropertyChanged.Fody to this issue.