You're most likely allocating new Bitmaps, which aren't disposable. You should allocate a single WriteableBitmap
and update that instead. The linked documentation describes the process behind locking, updating, and unlocking a WriteableBitmap
On software I work on using live ultrasound images in WPF, I am receiving a Windows Forms Bitmap, which I copy into the WriteableBitmap directly using the native CopyMemory method. Even with this more complicated work, the CPU isn't strained too hard, and the memory usage never moves as long as I properly dispose what I can. Hopefully this example can help you:
// DLL returns images as a WinForms Bitmap
Bitmap bmp = myClass.getWinFormsBitmap();
// In my situation, the images are always 640 x 480.
BitmapData data = bmp.LockBits(new Rectangle(0, 0, 640, 480), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
this.writeableBitmap.Lock();
// Copy the bitmap's data directly to the on-screen buffers
NativeMethods.CopyMemory(this.writeableBitmap.BackBuffer, data.Scan0, ImageBufferSize);
// Moves the back buffer to the front.
this.writeableBitmap.AddDirtyRect(new Int32Rect(0, 0, 640, 480));
this.writeableBitmap.Unlock();
bmp.UnlockBits(data);
// Free up the memory of the WinForms bitmap
bmp.Dispose();
Where CopyMemory is defined as:
[DllImport("Kernel32.dll", EntryPoint = "RtlMoveMemory")]
public static extern void CopyMemory(IntPtr Destination, IntPtr Source, int Length);