Dear CodeProject Members,
I have been facing serious memory issues and they are driving me nutes. Currently I am making a terraria like game, as you can see on this video:
https://www.youtube.com/watch?v=bQ_9m-KkdBQ[
^]
I have been able to make a fully working chunk system, and so far have updated it so that I can have about 250 different kind of blocks. Although here is not where my problem lies I seem to be only gaining memory. It's driving me nuts and I have no idea why. This is what I mean:
http://i49.tinypic.com/2n7f32t.png
I tried drawing only with the graphics from the Paint Event itself but this resulted the same with even
more memory. Is this normal or am I seriously messing something up?
Here is my piece of code:
protected override void OnPaint(PaintEventArgs e)
{
e.Graphics.Clear(this.BackColor);
Bitmap _Bitmap = new Bitmap(this.ClientSize.Width, this.ClientSize.Height);
using (Graphics g = Graphics.FromImage(_Bitmap))
{
DrawWorld(g);
DrawPlayer(g);
DrawInformation(g);
}
e.Graphics.DrawImage(_Bitmap, 0, 0, this.ClientSize.Width, this.ClientSize.Height);
_Bitmap.Dispose();
e.Graphics.Flush();
GC.Collect();
GC.WaitForPendingFinalizers();
}
The funny thing is, is, that without even going out of the first chunk the issue still occurs, so it is not a chunk error. Which I have also checked over 100+ times.
Let me also add that this memory does not drop down to it's original amount after a while, people told me that.
Anyone ? Help ! :L