And I'm trying to kill a memory usage issue, after taking a few dozen images I can have a memory usage of over 1.5G in the task manager.
Now I've got a simplified version (that also has the memory issue)
(Code Also Attached)
ImageCreation.cs
using System.Drawing;
using System.Drawing.Imaging;
namespace VidMemLeakDebug
{
class ImageCreation
{
public static Bitmap GiveMeAnImage()
{
Bitmap ImageToReturn = new Bitmap(1920, 1080, PixelFormat.Format16bppRgb565);
return ImageToReturn;
}
}
}
Form1.CS
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Windows.Forms;
namespace VidMemLeakDebug
{
public partial class Form1 : Form
{
private static Bitmap MyStaticUpImage = new Bitmap(1920, 1080, PixelFormat.Format16bppRgb565);
private static Bitmap MyStaticDownImage = new Bitmap(1920, 1080, PixelFormat.Format16bppRgb565);
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
using (Bitmap TempBitmap = ImageCreation.GiveMeAnImage())
{
MyStaticUpImage = new Bitmap(TempBitmap);
}
}
private void button2_Click(object sender, EventArgs e)
{
MyStaticDownImage.Save("JunkUpImage.bmp");
MyStaticUpImage.Save("JunkUpImage.bmp");
}
private void button3_Click(object sender, EventArgs e)
{
using (Bitmap TempBitmap = ImageCreation.GiveMeAnImage())
{
MyStaticDownImage = new Bitmap(TempBitmap);
}
}
}
}
How the program works.
The user might need to take dozens of Up and Or Down images before they have a valid set that can be save, so each image from the ImageCreation.GiveMeAnImage() is stored in a local static Bitmap (Either UpImage or DownImage) depending on what button they push.
Then when they are stratified, they can save the image pair.
now when I first start I'm getting about 15Mem Memory Usage ( ImageUp & ImageDown are created at startup)
But when I take each "picture" the memory jumps by about 8-9 Meg, and never comes down (I thought the Using(){} was supposed to clean that up)
How can I copy my temporary Image (from GiveMeAnImage) to my Static Image Buffers without having it recreate a new buffer each time?


Sign In
Create Account



Back to top









