Basically, in my program I have to create and destroy a window. I always use the same window pointer creating and destroying the contents (texture and render).
I notice a memory leak in this process so I wrote a simple program to verify this, here the code
#include <iostream>
#include "SDL.h"
int main(int argc, char *argv[])
{
SDL_Init(SDL_INIT_VIDEO);
SDL_Window* mainWindow;
SDL_Renderer* mainRenderer;
SDL_Texture* mainTexture;
for (int i = 0; i < 20; i++)
{
mainWindow = SDL_CreateWindow("Memory Leak Test v1.0", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 320, 240, SDL_WINDOW_SHOWN);
mainRenderer = SDL_CreateRenderer(mainWindow, -1, SDL_RENDERER_ACCELERATED);
mainTexture = SDL_CreateTexture(mainRenderer, SDL_PIXELFORMAT_ABGR8888, SDL_TEXTUREACCESS_STREAMING, 320, 240);
if (i == 0)
{
std::cout << "SDL Memory Leak Tester, please check the amount of memory\noccupied by the process, then press Enter\n";
getchar();
}
SDL_Delay(1000);
if (i == 19)
{
std::cout << "SDL Memory Leak Tester, please check the amount of memory\noccupied by the process, then press Enter\n";
getchar();
}
SDL_DestroyTexture(mainTexture);
SDL_DestroyRenderer(mainRenderer);
SDL_DestroyWindow(mainWindow);
}
std::cout << "Test finished, press Enter to close\n";
getchar();
return 0;
}
Any idea?
Aucun commentaire:
Enregistrer un commentaire