Hi all, I'm trying to work with GDI+ and I'm running into a weird memory leak. I have a vector
of GdiplusBase
pointers, all of them dynamically created. The odd thing is, though, is that if I try to delete the objects as GdiplusBase
pointers, e.g.
vector<GdiplusBase*> gdiplus;
gdiplus.push_back(new Image(L"filename.jpg"));
delete gdiplus[0];
The object is not deleted and memory leaks (according to Task Manager). However, if I cast back to the original pointer and then delete,
delete (Image*)gdiplus[0];
The object is correctly deleted. The strange this about this, as far as I can tell, is that (according to MSDN) GdiplusBase
is the base class of all GDI+ objects and owns the delete operators for all of them. In that case, shouldn't delete gdiplus[0];
work correctly and free the memory? Am I doing anything wrong here?
Thanks in advance