payload: {"action":"opened","issue":{"url":"https://api.github.com/repos/emgucv/emgucv/issues/256","repository_url":"https://api.github.com/repos/emgucv/emgucv","labels_url":"https://api.github.com/repos/emgucv/emgucv/issues/256/labels{/name}","comments_url":"https://api.github.com/repos/emgucv/emgucv/issues/256/comments","events_url":"https://api.github.com/repos/emgucv/emgucv/issues/256/events","html_url":"https://github.com/emgucv/emgucv/issues/256","id":462301881,"node_id":"MDU6SXNzdWU0NjIzMDE4ODE=","number":256,"title":"Memory leaks with EmguCV.Stitching.Stitcher.Stitch()","user":{"login":"DrSilbermann","id":52351237,"node_id":"MDQ6VXNlcjUyMzUxMjM3","avatar_url":"https://avatars0.githubusercontent.com/u/52351237?v=4","gravatar_id":"","url":"https://api.github.com/users/DrSilbermann","html_url":"https://github.com/DrSilbermann","followers_url":"https://api.github.com/users/DrSilbermann/followers","following_url":"https://api.github.com/users/DrSilbermann/following{/other_user}","gists_url":"https://api.github.com/users/DrSilbermann/gists{/gist_id}","starred_url":"https://api.github.com/users/DrSilbermann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DrSilbermann/subscriptions","organizations_url":"https://api.github.com/users/DrSilbermann/orgs","repos_url":"https://api.github.com/users/DrSilbermann/repos","events_url":"https://api.github.com/users/DrSilbermann/events{/privacy}","received_events_url":"https://api.github.com/users/DrSilbermann/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2019-06-29T13:18:31Z","updated_at":"2019-06-29T13:18:31Z","closed_at":null,"author_association":"NONE","body":"I use the Emgu.CV.Stiching Class for the stitching algorithm, an although i try to dispose the resources correctly i get huge memory leaks, depending on the amount and size of the images i use. \r\n\r\nI am using VS 2015 and EmguCV Version 4.1.0.3420 and running a Debug Build.\r\nHere is a minimal reproducible example of my code:\r\n\r\n    using System;\r\n    using System.IO;\r\n\r\n    using Emgu.CV;\r\n    using Emgu.CV.Structure;\r\n    using Emgu.CV.Stitching;\r\n    using Emgu.CV.Util;\r\n    using Emgu.CV.Features2D;\r\n    using Emgu.CV.CvEnum;\r\n\r\n    namespace Example\r\n    {\r\n        class Program\r\n        {\r\n            static void Main(string[] args)\r\n            {\r\n                string folderPath = @\"e:\\Users\\Dennis\\Desktop\\Stitching\\ExampleImages2\";       //Paste your the path of your folder, which contains the images, here       \r\n                string format = \".jpg\";\r\n                string[] filePaths = Directory.GetFiles(folderPath, (\"*\" + format));\r\n                string storagePath;\r\n\r\n                Directory.CreateDirectory(folderPath + @\"\\Stitched\");                                               //creates new Directionary if not exist\r\n                int num = 1;                                                                                        //Sets file numbering\r\n                while (true)                                                                                        //Checks if there is already an exisitng file with that name and change numbering \"num\" if \"true\"\r\n                {\r\n                    storagePath = folderPath + @\"\\Stitched\" + @\"\\result_\" + num + format;\r\n\r\n                    if (!File.Exists(storagePath))\r\n                        break;\r\n                    num++;\r\n                }\r\n\r\n\r\n\r\n                //Image Stitching\r\n\r\n                Stitcher.Mode mode = Stitcher.Mode.Scans;\r\n                float threshhold = 0.0001f;\r\n                Mat result = new Mat();\r\n\r\n                using (Stitcher stitcher = new Stitcher(mode))                                                  //Creates a Stitcher configured with one of the stitching modes\r\n                using (AKAZE detector = new AKAZE(AKAZE.DescriptorType.Mldb, 0, 3, threshhold))                 //Creates a Feature Detector with a user-chosen threshhold\r\n                using (VectorOfMat input = new VectorOfMat())\r\n                {\r\n                    stitcher.SetFeaturesFinder(detector);\r\n\r\n                    Mat[] images = new Mat[filePaths.Length];\r\n\r\n                    for (int i = 0; i < filePaths.Length; i++)\r\n                    {\r\n                        images[i] = CvInvoke.Imread(filePaths[i], ImreadModes.AnyColor);\r\n                    }\r\n\r\n                    input.Push(images);\r\n\r\n                    for (int i = 0; i < filePaths.Length; i++)\r\n                    {\r\n                        images[i].Dispose();\r\n                    }\r\n\r\n                    stitcher.Stitch(input, result);\r\n\r\n                }\r\n\r\n                using (Image<Bgr, Byte> resImage = result.ToImage<Bgr, Byte>())\r\n                {\r\n                    resImage.Save(storagePath);\r\n                }\r\n\r\n                result.Dispose();\r\n\r\n\r\n                Console.ReadKey();              //I included this, so the program wont stop and you can see, how the mempry consumption graph is not falling\r\n            }\r\n\r\n        }\r\n    }\r\n\r\n[dotnetfiddle.net/x6Iy1Q](url) shows that the managed memory usage is less than 1MB - virtually all of the memory usage is unmanaged.  I am stitching images of very high resolution so i would be really thankful if this issue could be fixed."}}
other: {"actor":{"display_login":"DrSilbermann"}}