1

This code will explain the plot:

// on init:

m_mainWindow = SDL_CreateWindow("title", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 480, 640, SDL_WINDOW_SHOWN);
m_mainRenderer = SDL_CreateRenderer(m_mainWindow, -1, 0); // + 8 Mb of memory

// on screen resize when my ios sends SDL_WINDOWRESIZED:
SDL_DestroyRenderer(m_mainRenderer); // - 1!!! Mb of memory

m_mainRenderer = SDL_CreateRenderer(m_mainWindow, -1, 0); // + 6 Mb of memory

I can't fully destroy renderer and clear memory of it. why? and what I did wrong here?

Martin G
  • 17,357
  • 9
  • 82
  • 98
  • Try calling it in a loop, does the memory usage increase? – this Dec 29 '13 at 10:32
  • Question name is misguiding, I don't think it can be called a memory leak. Most likely some system (or SDL) memory allocation shenaningans. – pampeho Dec 29 '13 at 12:07
  • 1
    how do you measure the memory changes?? – UmNyobe Dec 29 '13 at 12:31
  • 1
    Are you using C or C++? Based on the code sample it appears to be C. Regardless **Please do not tag a question both C and C++, there are very different answers for each language** – Mgetz Dec 29 '13 at 14:31
  • I did it several times in session and it grew up from 38 Mb to 600+ just with this operation. Used Task manager to view memory activity and writing with c++. Sorry for tags. i'm new to stackoverflow and it somehow taged my question automaticaly. – FertoVordalastr Dec 29 '13 at 15:36
  • @FertoVordalastr Post a [sscce](http://www.sscce.org). – this Dec 29 '13 at 17:16
  • Is this on Windows or Linux, 32 or 64 bit? – cup Dec 29 '13 at 21:06

1 Answers1

2

You don't need to create a Renderer at each Resize, your renderer size will be updated automatically... Basically, you can do everything in your software with ONLY ONE renderer. By the way, the SDL_Renderer doesn't contains dimension attributes, the windows contains it and the SDL_Renderer is linked to that Window

jordsti
  • 746
  • 8
  • 12