I downloaded gpu-z, which shows how much of gpu memory is in use. I checked memory load when each map is created in separate runtimes and when one is created after deletion of another. whenn i load map2 after map 1 during one runtime i see more memory used.
Anyway i might have screwed something with new/delete routine, i'll admit i don't have much experience with that. I'll paste few snippets regarding loading/reloading a map.
Controler.cpp:
void TestControler::level_selector()
{
switch ( selector )
{
case 2:
std::cout << "loading Mine level..." << std::endl;
currentLevel = new MineLevel(world, window, rayCallback);
break;
case 3:
std::cout << "loading City level..." << std::endl;
currentLevel = new CityLevel(world, window, rayCallback);
break;
///etc...
}
}
//and when i want to switch level:
void TestControler::check_for_destructors()
{
if (switchLevel)
{
delete currentLevel;
currentLevel = new AnotherLevel(world, window, rayCallback);
switchLevel = false;
}
}
And constructor and destructor for one of the levels.
CaveLevel::CaveLevel(b2World *aWorld, sf::RenderWindow * aWindow,RayCastListener * rayCast) : world(aWorld), window(aWindow)
{
load_resources();
set_layers();
set_chains();
ls = new ltbl::LightSystem(AABB(Vec2f(0.0f, 0.0f), Vec2f(1680.0f,1050.0f)), window, "data/lightFin.png", "data/shaders/lightAttenuationShader.frag");
rayCallback = rayCast;
hero = new Hero(world, ls,1100, 735, sitting, rayCallback);
camera = new Camera(hero);
setup_lights();
setup_audio();
}
CaveLevel::~CaveLevel()
{
delete hero;
delete camera;
delete ls;
}
All the textures are private members of level class, and they are loaded in load_resources() function.