Sign in to follow this  
Talyrond

Out of Video Card Memory

Recommended Posts

Hi all first let me preface my question by saying that I am very new to DirectX. I am having a problem with 'Out of Video Card Memory' exceptions. This is managed code by the way. I quite often am recreating my Vertex buffer (I have one large one), and after a while I get the error. I guess that I am filling up my Video cards memory without releasing it every time, see the code below. I have added the Dispose method as you can see, this seems to help but I would like to know if I am doing thing correctly? Try Me.VertexBuffer.Dispose() Me.VertexBuffer = New VertexBuffer(GetType(CustomVertex.PositionColored), numOfIndices, Me.ChildForm.ClientArea.Device, Usage.Dynamic Or Usage.WriteOnly, CustomVertex.PositionColored.Format, Pool.Default) Catch ex As OutOfVideoMemoryException MessageBox.Show("Out of Video Card Memory", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) Catch ex As Exception MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try

Share this post


Link to post
Share on other sites
The call to Dispose should release the memory, and not using it would likely eventually cause an OutOfMemory error. Do you still get the error now that you've added it?

Also, you should make sure to only Dispose of the buffer if it has been initialized. Something like:

If Me.VertexBuffer = Nothing Then
Me.VertexBuffer.Dispose()
Me.VertexBuffer = Nothing
End If

Hope this helps :).

Share this post


Link to post
Share on other sites
Hi, yes it seems OK, although when filling the vb for the first time with a large number, I can get the message but I am using a lot of vertices, say 4 million, I have 128mb of Ram, sound about right or are you surprised at that?

Cheers

Julian

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this