I am using the Ogre engine but my issue is related directly with DirectX. I sometime get this error message when loading my game:
14:40:16: OGRE EXCEPTION(3:RenderingAPIException): Error creating texture: Ran out of memory in D3D9Texture::_createCubeTex at ..\..\..\Ogre_1_7_2\RenderSystems\Direct3D9\src\OgreD3D9Texture.cpp (line 1218)
The HRESULT returned by D3DXCreateCubeTexture is E_OUTOFMEMORY. The texture in question is a cubemap (always the same that fails), 6 faces of 1024x1024.
My games runs fine for a very long period of time. We tested it up to 60 hours, loading and playing the game over 600 times without a restart. However, in a very precise case, I will get the above error on the first loading. It happens when I add the following code before doing any resource loading:
char* tests[12800];
for(unsigned int j=0; j<12800; j++)
tests[j] = new char[51200];
for(unsigned int j=0; j<12800; j++)
delete []tests[j];
This code allocates 625mb in blocks on 50kb, then frees it immediately. It basically have no effect except messing around with the memory, yet it causes the DX issue when loading a cubemap. I know for a fact that I still have plenty of ram available and it is not the reason for the error. I read somewhere that directx resources need some "kernel memory" and that might be the problem, so I verified using the task manager and it seems to be fine on this side.
I am pretty beginner with these kind of complex memory management and I'm very confused on why DX would run out of memory. I'm sure it is not a memory overwrite issue because the behavior is not consistent at all with this kind of bugs. So any help would be very appreciated, even if you have no idea what the issue is, maybe just pointers or tips on where to look or tools I can use to help me debugging is welcomed.
Thanks,
- Matt