mirabyte Forum

Full Version: Slide animator uses a lot of memory
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Maybe it's anothere library i'm using but I can go to other forms from my home form 8 or 9 times and then I get exceptions like "out of memory".


Is there anything wrong with the code i'm using? I need to do it this way because the touchlistbox doesn't slide away. The background slide beneath it.

To speed things up, I created 2 bitmaps before using this function..

Code:
private void StartForm(Form Frm)
        {
            SlideAnimator tSlideAnimator;
            Graphics tGraphicsBuffer;
            tGraphicsBuffer = this.CreateGraphics();
            tSlideAnimator = new SlideAnimator(_bmImageOne, _bmImageTwo, tGraphicsBuffer);
            tSlideAnimator.BackgroundColor = System.Drawing.Color.Red;

            if (!_StopAnimation)
            {
                try
                {
                    tlbMenu.Visible = false; //Hide, because the Animation doesn't move it
                    tSlideAnimator.Animate(SlideAnimator.SlideDirection.sdLeft);

                    Frm.ShowDialog();
                    Frm.Dispose();
                }
                catch
                {
                    _StopAnimation = true;
                }
            }


            if (!_StopAnimation)
            {
                try
                {
                    tSlideAnimator = new SlideAnimator(_bmImageTwo, _bmImageOne, tGraphicsBuffer);
                    tSlideAnimator.Animate(SlideAnimator.SlideDirection.sdRight);
                }
                catch
                {
                    _StopAnimation = true;
                }
            }
            tGraphicsBuffer.Dispose();

            if (!tlbMenu.Visible) //Show again
            {
                tlbMenu.Visible = true;
            }
        }
You have to Dispose() _bmImageOne and _bmImageTwo. Otherwise it will be still stored in memory.
(23-03-2010 12:33)Sascha Lange Wrote: [ -> ]You have to Dispose() _bmImageOne and _bmImageTwo. Otherwise it will be still stored in memory.

These are local vars.

I need to use bitmap.dispose(); ?
In your case _bmImageOne and _bmImageTwo are bitmaps, so you have to dispose them after you are finished with SlideAnimator:

_bmImageOne.Dispose();
_bmImageTwo.Dispose();
Reference URL's