- getting fanatical about memory cleanup so that valgrind output is more useful

This commit is contained in:
Mark Vejvoda
2011-09-30 23:55:07 +00:00
parent b57fb0ff39
commit 77a2fa7d48
6 changed files with 84 additions and 84 deletions

View File

@@ -39,6 +39,8 @@
#include <iterator>
#include "core_data.h"
#include "font_text.h"
//#include "FileReader.h"
//#include "JPGReader.h"
//#include "sound.h"
//#include "unicode/uclean.h"
@@ -87,6 +89,7 @@ using namespace Shared::Util;
using namespace Shared::Graphics;
using namespace Shared::Graphics::Gl;
using namespace Shared::Xml;
using namespace Shared;
namespace Glest{ namespace Game{
@@ -160,17 +163,25 @@ static void cleanupProcessObjects() {
//deleteMapValues(crcFactionPreviewTextureCache.begin(),crcFactionPreviewTextureCache.end());
crcFactionPreviewTextureCache.clear();
printf("running threads = %lu\n",Thread::getThreadList().size());
time_t elapsed = time(NULL);
for(;Thread::getThreadList().size() > 0 &&
difftime(time(NULL),elapsed) <= 10;) {
sleep(0);
sleep(10);
}
SystemFlags::globalCleanupHTTP();
CacheManager::cleanupMutexes();
std::map<string, vector<FileReader<Pixmap2D> const * >* > &list2d = FileReader<Pixmap2D>::getFileReadersMap();
//printf("list2d = %lu\n",list2d.size());
deleteMapValues(list2d.begin(),list2d.end());
std::map<string, vector<FileReader<Pixmap3D> const * >* > &list3d = FileReader<Pixmap3D>::getFileReadersMap();
//printf("list3d = %lu\n",list3d.size());
deleteMapValues(list3d.begin(),list3d.end());
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
SystemFlags::SHUTDOWN_PROGRAM_MODE=true;
SystemFlags::globalCleanupHTTP();
CacheManager::cleanupMutexes();
}
#if defined(WIN32) && !defined(_DEBUG) && !defined(__GNUC__)