0

I am currently working on a 2d platformer game in C++. I have a class called Tilemap which stores the actual data for the tilemap in a 2D int vector. I noticed that when the player dies and I restart the level the process memory goes up by about 1 Megabyte. So I used Visual Leak Detector and it detected 114 memory leaks all originating from the initialization of my 2D int vector. Here's my code:

std::vector<std::vector<int>> tileMapArray;
tileMapArray.resize(mapSizeX);
for (int i = 0; i < mapSizeX; i++)
    tileMapArray[i].resize(mapSizeY);

Is there a way to fix this? Thanks in advance, TheKrane


EDIT: Those are the lines that VLD tells me the leaks occur at:

main.cpp(30):

Scene* currentLevel = new Level;

level.cpp(6):

Level::Level() : m_Tilemap("Data/testlevel.tmx", "Data/tilemap.png") {}

tilemap.cpp(36):

for (int i = 0; i < mapSizeX; i++)
    tileMapArray[i].resize(mapSizeY);
TheKrane
  • 3
  • 2

0 Answers0