diff options
author | sr55 <[email protected]> | 2015-01-10 18:37:52 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2015-01-10 18:37:52 +0000 |
commit | e893c87e5ce55af2ceb2d9a0291f614ea312d0d1 (patch) | |
tree | e24f11db3b9bef61b013fe14486ac90bbb206da3 | |
parent | 2d7ab4d15eb9ea450787831445cbf79d5192d18c (diff) |
WinGui: Fix a large memory leak in the preview window that was introduced with the switch to _preview2
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6725 b64f7644-9d1e-0410-96f1-a4d463321fa5
3 files changed, 11 insertions, 1 deletions
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs index a77f36ddb..cdb368c9a 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HandBrakeInstance.cs @@ -348,6 +348,12 @@ namespace HandBrake.Interop bitmap.UnlockBits(bitmapData);
+ // Close the image so we don't leak memory.
+ IntPtr nativeJobPtrPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(IntPtr)));
+ Marshal.WriteIntPtr(nativeJobPtrPtr, resultingImageStuct);
+ HBFunctions.hb_image_close(nativeJobPtrPtr);
+ Marshal.FreeHGlobal(nativeJobPtrPtr);
+
// Create a Bitmap Image for display.
using (var memoryStream = new MemoryStream())
{
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/HbFunctions.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/HbFunctions.cs index 2b1e4a770..8721784e8 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/HbFunctions.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/HbLib/HbFunctions.cs @@ -452,6 +452,11 @@ namespace HandBrake.Interop.HbLib [DllImport("hb.dll", EntryPoint = "hb_get_preview2", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr hb_get_preview2(IntPtr hbHandle, int title_idx, int preview_idx, ref hb_geometry_settings_s geo, int deinterlace);
+ // void hb_image_close(hb_image_t **_image);
+ [DllImport("hb.dll", EntryPoint = "hb_image_close", CallingConvention = CallingConvention.Cdecl)]
+ public static extern IntPtr hb_image_close(IntPtr image);
+
+
/* JSON API */
// char * hb_get_title_set_json(hb_handle_t * h);
diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Factories/AnamorphicFactory.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Factories/AnamorphicFactory.cs index 598fedac1..97809c348 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Factories/AnamorphicFactory.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/Json/Factories/AnamorphicFactory.cs @@ -107,6 +107,5 @@ namespace HandBrake.Interop.Json.Factories };
return geometry;
}
-
}
}
|