Click here to Skip to main content
14,327,634 members

Silverlight / WPF

 
GeneralRe: Passing table value params to Sql Server from WPF app Pin
Richard Deeming6-Mar-18 1:29
mveRichard Deeming6-Mar-18 1:29 
GeneralRe: Passing table value params to Sql Server from WPF app Pin
Christopher Duncan6-Mar-18 1:32
memberChristopher Duncan6-Mar-18 1:32 
QuestionScrollbars Not Enabling Pin
Kevin Marois1-Mar-18 5:52
professionalKevin Marois1-Mar-18 5:52 
AnswerRe: Scrollbars Not Enabling Pin
Gerry Schmitz2-Mar-18 9:59
mveGerry Schmitz2-Mar-18 9:59 
QuestionHighlight Searched Text with ListView in WPF Pin
Member 1313673327-Feb-18 14:17
memberMember 1313673327-Feb-18 14:17 
AnswerRe: Highlight Searched Text with ListView in WPF Pin
Richard MacCutchan27-Feb-18 21:26
protectorRichard MacCutchan27-Feb-18 21:26 
AnswerRe: Highlight Searched Text with ListView in WPF Pin
Gerry Schmitz28-Feb-18 7:53
mveGerry Schmitz28-Feb-18 7:53 
QuestionWPF memory leak BitmapImage Pin
Leif Simon Goodwin21-Feb-18 1:53
memberLeif Simon Goodwin21-Feb-18 1:53 
We have some code which receives images of a document from a C++ DLL, and displays them in a WPF application. The C# code stores the images in an array, which it flushes each time a new document is placed on the scanner. The code converts the image from a Bitmap to a BitmapImage, which is the image type for display in WPF:

private BitmapImage CreateBitmapImage(Bitmap bitmap)
{
    using (MemoryStream memory = new MemoryStream())
    {
        bitmap.Save(memory, ImageFormat.Bmp);
        memory.Position = 0;
        BitmapImage bitmapimage = new BitmapImage();
        bitmapimage.BeginInit();
        bitmapimage.StreamSource = memory;
        bitmapimage.CacheOption = BitmapCacheOption.OnLoad;
        bitmapimage.EndInit();
        bitmapimage.Freeze();
        return bitmapimage;
    }
}


The above code leaks, but only on some PCs. On most it is okay. It can be fine on one Windows 10 PC, and leak on another that has Windows 10 on the same hardware.

A key point to note is that the DLL module is also passing the bitmap handle to a third party validation DLL, and if we remove that DLL, the memory leak disappears.

If I remove the Freeze() call, the code does not leak, but the images are not displayed.

If I comment out the return call, and return null instead, the code still leaks. Therefore the issue is not that we do not clear the stored images.

That this only occurs on some PCs, might suggest a timing issue associated with the validation DLL.

Thoughts? Smile | :)

Note: Edited to correct the code. For some reason I'd copied it with a key line missing!

modified 22-Feb-18 11:29am.

AnswerRe: WPF memory leak BitmapImage Pin
#realJSOP22-Feb-18 1:32
mve#realJSOP22-Feb-18 1:32 
GeneralRe: WPF memory leak BitmapImage Pin
Leif Simon Goodwin22-Feb-18 5:30
memberLeif Simon Goodwin22-Feb-18 5:30 
AnswerRe: WPF memory leak BitmapImage Pin
MadMyche22-Feb-18 4:09
mveMadMyche22-Feb-18 4:09 
GeneralRe: WPF memory leak BitmapImage Pin
Leif Simon Goodwin22-Feb-18 5:31
memberLeif Simon Goodwin22-Feb-18 5:31 
GeneralRe: WPF memory leak BitmapImage Pin
MadMyche22-Feb-18 8:31
mveMadMyche22-Feb-18 8:31 
GeneralRe: WPF memory leak BitmapImage Pin
Leif Simon Goodwin23-Feb-18 2:36
memberLeif Simon Goodwin23-Feb-18 2:36 
AnswerRe: WPF memory leak BitmapImage Pin
Gerry Schmitz22-Feb-18 4:46
mveGerry Schmitz22-Feb-18 4:46 
GeneralRe: WPF memory leak BitmapImage Pin
Leif Simon Goodwin22-Feb-18 5:29
memberLeif Simon Goodwin22-Feb-18 5:29 
GeneralRe: WPF memory leak BitmapImage Pin
Gerry Schmitz22-Feb-18 5:54
mveGerry Schmitz22-Feb-18 5:54 
GeneralRe: WPF memory leak BitmapImage Pin
Leif Simon Goodwin22-Feb-18 23:57
memberLeif Simon Goodwin22-Feb-18 23:57 
AnswerRe: WPF memory leak BitmapImage Pin
Leif Simon Goodwin8-Mar-18 22:35
memberLeif Simon Goodwin8-Mar-18 22:35 
Question"Cylinder lens" scrollbar Pin
Member 798912219-Feb-18 3:33
memberMember 798912219-Feb-18 3:33 
AnswerRe: "Cylinder lens" scrollbar Pin
Gerry Schmitz19-Feb-18 6:53
mveGerry Schmitz19-Feb-18 6:53 
GeneralRe: "Cylinder lens" scrollbar Pin
Member 798912219-Feb-18 22:18
memberMember 798912219-Feb-18 22:18 
QuestionPassing Data From a window to the mainview(shellViewModel) using EventAggregator - WPF Caliburn.Micro Pin
Dwayne Barsotta27-Jan-18 6:05
memberDwayne Barsotta27-Jan-18 6:05 
AnswerRe: Passing Data From a window to the mainview(shellViewModel) using EventAggregator - WPF Caliburn.Micro Pin
Gerry Schmitz27-Jan-18 12:10
mveGerry Schmitz27-Jan-18 12:10 
GeneralRe: Passing Data From a window to the mainview(shellViewModel) using EventAggregator - WPF Caliburn.Micro Pin
Dwayne Barsotta27-Jan-18 12:20
memberDwayne Barsotta27-Jan-18 12:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.