   Disappearing sprite
  I wrote a very simple chunk of code that displays a movable sprite on the screen, but for some reason the sprite disappears after about a minute.  Furthermore, the longer the program runs, the longer it takes to close.  This is very odd to me, and I would like to know what the problem is.  Here is the source code for my main file:#include "driver.h"LPDIRECT3DSURFACE9 back;LPD3DXSPRITE sprite_handler;LPDIRECT3DTEXTURE9 sprite;HRESULT result;int x,y;void render(HWND hwnd){if (KeyDown(DIK_LEFT))   x -= 10;if (KeyDown(DIK_RIGHT))   x += 10;if (KeyDown(DIK_DOWN))   y += 10;if (KeyDown(DIK_UP))   y -= 10;//start rendering    if (d3ddev->BeginScene())    {   //erase the entire background   d3ddev->ColorFill(backbuffer, NULL, D3DCOLOR_XRGB(0,0,0));   d3ddev->StretchRect(back, NULL, backbuffer, NULL, D3DTEXF_NONE);//start sprite handlersprite_handler->Begin(D3DXSPRITE_ALPHABLEND);D3DXVECTOR3 position(0,0,0);//block position vectorsprite = LoadTexture("spriteskeletoncolored.bmp", D3DCOLOR_XRGB(255, 0, 255));position.x = x;position.y = y;sprite_handler->Draw(sprite, NULL,NULL,&position,D3DCOLOR_RGBA(255,246,240,255));sprite = LoadTexture("unchangeables.bmp", D3DCOLOR_XRGB(255, 0, 255));sprite_handler->Draw(sprite, NULL,NULL,&position,D3DCOLOR_RGBA(255,255,255,255));sprite = LoadTexture("changeables.bmp", D3DCOLOR_XRGB(255, 0, 255));sprite_handler->Draw(sprite, NULL,NULL,&position,D3DCOLOR_RGBA(86,181,247,255));sprite = LoadTexture("hair.bmp", D3DCOLOR_XRGB(255, 0, 255));sprite_handler->Draw(sprite, NULL,NULL,&position,D3DCOLOR_RGBA(75,51,19,255));sprite = LoadTexture("shadow.bmp", D3DCOLOR_XRGB(255, 0, 255));sprite_handler->Draw(sprite, NULL,NULL,&position,D3DCOLOR_RGBA(255,255,255,100));sprite = LoadTexture("sword.bmp", D3DCOLOR_XRGB(255, 0, 255));position.y += 25;position.x -= 1;sprite_handler->Draw(sprite, NULL,NULL,&position,D3DCOLOR_RGBA(255,255,255,255));//stop drawingsprite_handler->End();//stop renderingd3ddev->EndScene();}//display the back buffer on the screend3ddev->Present(NULL, NULL, NULL, NULL);}void Color_Init(HWND hwnd){back = LoadSurface("bg2.jpg", NULL);result = D3DXCreateSprite(d3ddev, &sprite_handler);x = 500;y = 500;}void Color_Run(HWND hwnd){Read_Mouse();Read_Keyboard();render(hwnd);if (KeyDown(DIK_ESCAPE))   PostMessage(hwnd, WM_QUIT, 0, 0);}void Color_End(){if(sprite_handler != NULL){sprite_handler->Release();}if(back != NULL){back->Release();}if(sprite != NULL){sprite->Release();}}
  You keep loading textures into the same handle without prior releasing. That's a memory leak.You should really only load them once at the start, not load them every frame.   ;  Thank you   ;  Well, one question actually.  I heard somewhere it was a good idea to do all of your rendering with one sprite.  But are you suggesting I instead make 5 different  LPDIRECT3DTEXTURE9s for each part of the sprite, and 5 different LPD3DXSPRITEs for each sprite handler?  It seems like this would really add up, given that each sprite would have many frames of animation.   