![]() I am working on a WPF application handling lists too long to fit in the window, so it needs a scroll bar. When running the WinForms test app, we have no leaks. If I add that DLL, we have leaks but only when running our WPF test app, or our WPF application. If I remove that DLL, our code shows no leaks. We use a third party DLL for document verification, which receives bitmaps from us. This can indicate that a Finalizer method is stuck, which will prevent instances from being finalized and cause memory leaks.". I memory profiled the WPF test app, and it said that "22 types have instances that are queued for finalization. The two apps use almost the same code, except that the WinForms overrides the form's WndProc, whereas the WPF app hooks its own WndProc onto the main window. It shows a huge memory leak consistent with the bitmap buffer leaking. I created a WPF app, which initialises VideoOCRWrapper and displays the received bitmap. It has converts the BitmapImage to a Bitmap for display.It shows no memory leaks. I created a WinForms app, which initialises VideoOCRWrapper and displays the received bitmap. On receipt of a bitmap, it converts it to a BitmapImage and fires an event to provide a client with the BitmapImage isntance. It essentially makes calls to a C++ DLL, and has a callback which receives a IntPtr containing a HWND. We have a small C# class - VideoOCRWrapper - which drives an attached OCR document scanner. I created test WPF and WinForms apps and the results are bizarre. I tried assigning a static buffer to the MemoryStream instance instead of allowing it to allocate its own buffer but that caused a crash. I found the source for MemoryStream and the Dispose method does NOT set the buffer reference to null. It appears to be unrelated to the version of. I’ll blog about how to remove Init methods later.Thank you to everyone for your thoughts. In this context, the only method I know about is Initialize(), whereas the “Init method” smell is a required method that must be called before calling other methods on the same class. ![]() While “ Init methods” is high on my list, the context here is different. P.S: Astute readers of my blog might recognize that I'm using an Initialize() method which I've called out as a bad habit on my On Notice Board. My next few posts will demonstrate how to really take advantage of this pattern. So there you have a basic initialization routine for all your background services.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |