Hi!
I've got a strange problem. I have a vector of CGapiSurfaces. I have problems destroying it.
When I run this code:
It works as expected: I have the same amount of memory after this than before. (I traced and watch it
by task manager and process explorer)
BUT if I leave out the delete surfaces[i] row (13), and rigth after the loop I run a second one:
the memory is not freed (or a few bytes only)
If I create once more the surfaces, it does not
allocate extra memory for it, it uses the not-freed memory.
I also tried surfaces[i]->FreeSurface(), and surfaces[i]->CreateSurface(GDSURFACE_SYSTEMMEMORY, DWORD(0), DWORD(0)) before deleting it, but they didn't help.
I tried with a static array as well, but the result is the same.
What can I do now?
Please, help
Thanks
I've got a strange problem. I have a vector of CGapiSurfaces. I have problems destroying it.
When I run this code:
- Code:
std::vector<CGapiSurface*> surfaces;
CGapiFileStream* stream = new CGapiFileStream();
HRESULT result = GD_OK;
TCHAR* file = new TCHAR[255];
for (DWORD i = 0 ; i < phases; i++)
{
CGapiSurface* surface = new CGapiSurface(m_pGapiDraw);
_strintf(file, fileName, i + 1);
result = stream->Open(vfs, file);
result =surface->CreateSurface(GDSURFACE_SYSTEMMEMORY, stream);
surfaces.push_back(surface);
stream->Close();
delete surfaces[i];
}
It works as expected: I have the same amount of memory after this than before. (I traced and watch it
by task manager and process explorer)
BUT if I leave out the delete surfaces[i] row (13), and rigth after the loop I run a second one:
- Code:
for ( i = 0 ; i < phases; i++)
delete surfaces[i]
the memory is not freed (or a few bytes only)
If I create once more the surfaces, it does not
allocate extra memory for it, it uses the not-freed memory.
I also tried surfaces[i]->FreeSurface(), and surfaces[i]->CreateSurface(GDSURFACE_SYSTEMMEMORY, DWORD(0), DWORD(0)) before deleting it, but they didn't help.
I tried with a static array as well, but the result is the same.
What can I do now?
Please, help
Thanks