blit out of memory exception

May 8, 2014 at 8:49 PM
I have one really large writeablebitmap and then I copy 33 small writeablebitmaps with function blit into the large one. For loading small bitmaps I use this function..
            BitmapImage img = new BitmapImage();
            img.CreateOptions = BitmapCreateOptions.None;
            Stream s = Application.GetResourceStream(new Uri(path, UriKind.Relative)).Stream;

            Image = new WriteableBitmap(img);

            img = null;
For example after 15 writeablebitmaps that were loaded I get error Out of memory exception, because the large writeablebitmap ate all memory. What I would like to do is to store writeablebitmap into the Image and then to use garbage collector to release memory for next image. This code didn't work. Can you explain how it works this function?