Archived

This topic is now archived and is closed to further replies.

Possibility

Crashs when releasing alot of VertexBuffers

Recommended Posts

In my game, I have tile based maps with each tile having a vertex buffer. When I increase the map size to large, it crashes when releasing vertex buffers. When I have the map size as 128x128 = 16384 VertexBuffers, its ok, but takes a while to release them all. But when I make the map like 256x256 = 65536 VertexBuffers, it crashes when releasing them all. Here is my release code:
  
for (int i = 0; i < 256; i++)
{
    for (int j = 0; j < 256; j++)
    {
        tile[i][j].m_VertexBuffer->Release();
    }
}
  
It wont finish the loop with a map size this large, I have to ctrl-alt-del the game which has stopped responding. Anyone know why it is crashing here if this is just to many VertexBuffers? I am using D3D8 with an athlon 650 + voodoo3. Possibility

Share this post


Link to post
Share on other sites
Anyone have any ideas? The runs perfectly fine, but doesnt crash until I exit and enter the for loops to release all the vertex buffers.

Possibility

Share this post


Link to post
Share on other sites
G''day!

Just a thought. Are you checking the return value when you create all your buffers? That''s a lot of buffers to allocate and if some of them fail you may be Release()ing buffers that were never allocated.


Stay Casual,

Ken
Drunken Hyena

Share this post


Link to post
Share on other sites
SWEET! I figured it out. With an extreme amount of vertex buffers as I have, they have to be released in reverse order of their creation.

My game actually wasnt crashing, it was just taking about 15min to release all the vertex buffers.

But when I reversed the order of their release like so:

  
for (int y = Map->m_MapHeight-1; y >= 0; y--)
for (int x = Map->m_MapWidth-1; x >= 0; x--)
Map->tile[y][x].InvalidateDeviceObjects();


it only took a few seconds!

And I have tried maps of size 512x512 (= 262,144 vertex buffers) and it still works fine.

Oh, and of course I do use SAFE_RELEASE.

Possibility

Share this post


Link to post
Share on other sites