Hi,
I wrote an sf::Image manager called "class imStorage" based on an
resource manager on the wiki and used Visual Studio 2010's debug mode to detect memory leaks.
For some reason, it's detecting a whole bunch of leaks, however I'm having trouble identifying what could be wrong.
Every image is stored on an std::map:
std::map<std::string,sf::Image*> bStore
Here's is the code for getting an image:
sf::Image *imStorage::GetImage(std::string Link)
{
//if the image is already in the map, then return the image from it
if(SearchManager(Link))
{
return bStore[Link];
}
//else allocate it from a Link to the path
else
{
sf::Image *bHolder = new sf::Image;
if(bHolder->LoadFromFile(Link))
{
bStore.insert(std::pair<std::string,sf::Image*>(Link,bHolder));
std::cout << "Gestor de Imagens $ Inserido: " << Link << std::endl;
return bStore[Link];
}
else
{
delete bHolder;
}
return NULL;
}
return NULL;
}
bool imStorage::SearchManager(std::string Link)
{
std::map<std::string,sf::Image*>::iterator it;
it = bStore.find(Link);
if(it != bStore.end())
{
return true;
}
else return false;
}
And finally here's the destructor:
imStorage::~imStorage()
{
while(bStore.begin()!=bStore.end())
{
delete bStore.begin()->second;
bStore.erase(bStore.begin());
}
}
I get the following messages after executing:
Detected memory leaks!
Dumping objects ->
{136} normal block at 0x00334C20, 8 bytes long.
Data: < S > 14 53 1F 00 00 00 00 00
{135} normal block at 0x00334BD0, 20 bytes long.
Data: < K3 K3 K3 > D0 4B 33 00 D0 4B 33 00 D0 4B 33 00 CD CD CD CD
{134} normal block at 0x00334B88, 8 bytes long.
Data: < I3 > D4 49 33 00 00 00 00 00
{133} normal block at 0x003349C8, 384 bytes long.
Data: <$ K3 > 24 CE 1E 00 01 00 00 00 01 00 00 00 88 4B 33 00
{132} normal block at 0x00334988, 4 bytes long.
Data: < I3 > C8 49 33 00
Object dump complete.
Problem is, I have no idea what these mean and I can't identify what's causing the leaks.
What could be wrong? Could it be a false positive? Should I use any other memory leak detection tool?
If you have any idea or suggestion please be sure to give me a heads up.
Thanks in advance