[WIP] Understanding memory leak in GetDisplayConfig

This commit is contained in:
Terry MacDonald 2022-03-25 22:57:32 +13:00
parent 37e336cb95
commit faaa61586c
2 changed files with 10 additions and 10 deletions

View File

@ -26,8 +26,8 @@ using System.Resources;
[assembly: Guid("e4ceaf5e-ad01-4695-b179-31168eb74c48")]
// Version information
[assembly: AssemblyVersion("2.2.0.261")]
[assembly: AssemblyFileVersion("2.2.0.261")]
[assembly: AssemblyVersion("2.2.0.264")]
[assembly: AssemblyFileVersion("2.2.0.264")]
[assembly: NeutralResourcesLanguageAttribute( "en" )]
[assembly: CLSCompliant(true)]

View File

@ -3954,8 +3954,8 @@ namespace DisplayMagicianShared.NVIDIA
int oneAdvTargetMemSize = Marshal.SizeOf(typeof(NV_DISPLAYCONFIG_PATH_ADVANCED_TARGET_INFO_V1));
IntPtr pathInfoPointer = Marshal.AllocHGlobal(onePathInfoMemSize * (int)PathInfoCount);
IntPtr sourceModeInfoPointer = Marshal.AllocHGlobal(oneSourceModeMemSize * (int)PathInfoCount);
IntPtr targetInfoPointer = Marshal.AllocHGlobal(onePathTargetMemSize * totalTargetInfoCount);
IntPtr advTargetPointer = Marshal.AllocHGlobal(oneAdvTargetMemSize * totalTargetInfoCount);
IntPtr targetInfoPointer = Marshal.AllocHGlobal(onePathTargetMemSize * totalTargetInfoCount * (int)PathInfoCount);
IntPtr advTargetPointer = Marshal.AllocHGlobal(oneAdvTargetMemSize * totalTargetInfoCount * (int)PathInfoCount);
// Also set another memory pointer to the same place so that we can do the memory copying item by item
// as we have to do it ourselves (there isn't an easy to use Marshal equivalent)
IntPtr currentPathInfoPointer = pathInfoPointer;
@ -4071,10 +4071,10 @@ namespace DisplayMagicianShared.NVIDIA
Marshal.FreeCoTaskMem(targetInfoPointer);
Marshal.FreeCoTaskMem(advTargetPointer);
Marshal.FreeCoTaskMem(currentPathInfoPointer);
Marshal.FreeCoTaskMem(currentSourceModeInfoPointer);
Marshal.FreeCoTaskMem(currentTargetInfoPointer);
Marshal.FreeCoTaskMem(currentAdvTargetPointer);
currentPathInfoPointer = IntPtr.Zero;
currentSourceModeInfoPointer = IntPtr.Zero;
currentTargetInfoPointer = IntPtr.Zero;
currentAdvTargetPointer = IntPtr.Zero;
}
}
@ -4171,8 +4171,8 @@ namespace DisplayMagicianShared.NVIDIA
Marshal.FreeCoTaskMem(pathInfoPointer);
Marshal.FreeCoTaskMem(sourceModeInfoPointer);
Marshal.FreeCoTaskMem(currentPathInfoPointer);
Marshal.FreeCoTaskMem(currentSourceModeInfoPointer);
currentPathInfoPointer = IntPtr.Zero;
currentSourceModeInfoPointer = IntPtr.Zero;
}