Hello There, Guest! (LoginRegister)

Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Slide animator uses a lot of memory
Author Message
ajhvdb Offline
Junior Member
**

Posts: 12
Joined: Mar 2010
Post: #1
Slide animator uses a lot of memory
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;
            }
        }
07-03-2010 19:41
Find all posts by this user Quote this message in a reply
Sascha Lange Offline
Administrator
*******

Posts: 298
Joined: Dec 2008
Post: #2
RE: Slide animator uses a lot of memory
You have to Dispose() _bmImageOne and _bmImageTwo. Otherwise it will be still stored in memory.

mirabyte Software-Entwickler / Software-Engineer
23-03-2010 12:33
Find all posts by this user Quote this message in a reply
ajhvdb Offline
Junior Member
**

Posts: 12
Joined: Mar 2010
Post: #3
RE: Slide animator uses a lot of 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(); ?
23-03-2010 13:11
Find all posts by this user Quote this message in a reply
Sascha Lange Offline
Administrator
*******

Posts: 298
Joined: Dec 2008
Post: #4
RE: Slide animator uses a lot of memory
In your case _bmImageOne and _bmImageTwo are bitmaps, so you have to dispose them after you are finished with SlideAnimator:

_bmImageOne.Dispose();
_bmImageTwo.Dispose();

mirabyte Software-Entwickler / Software-Engineer
23-03-2010 13:20
Find all posts by this user Quote this message in a reply
Post Reply