I have a function that returns an array of bytes containing the data of a bmp img live from a camera (including header). I write that array in to a MemoryStream object. That object, I pass to a Image object constructor, which will be passed to a PictureBox.
tl;dr:
byte[] AoB = GetImage();
MemoryStream ms = new MemoryStream();
ms.Write(AoB, 0, AoB.Length);
pictureBoxImage.Image = Image.FromStream(ms);
ms.Dispose();
All of this is done in a timer with a delay of 200 ms (5fps). It works fine for about a minute or 2 until OutOfMemory exception. For some reason, even though I dispose of the memory used, it keeps generating new one. I've also tried to declare ms as global and flush it every time, still no go. How can I stream the images while using the same memory space?