Sign in to follow this  

DX9 Locking up my whole computer

This topic is 4136 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

ok so heres my problem du jour I have this textured square, and it is moving up and down (I am all happy with myself at this point) So I just leave it running and go get lunch. Finish lunch, and start reading the next chapter in the book i'm going by. after a while (probably 20 minutes of running) it stops moving. My entire computer stopped responding, however if i hit ctr-alt-del, the cursor would blink to an hour glass for a second. but other than that frozen solid nothing to do but reset the computer. Now my question is am i not releasing something i should be that is slowly filling up memory until crunch? here is my render code, I will put the rest of it up if need be :)
////////////////////////////////////////////////////////
// Render()
////////////////////////////////////////////////////////
void Render()
{
        QueryPerformanceCounter (&LI_CurrentCount);
        D_CurrentCount          = LI_CurrentCount.QuadPart;
        I_TimeSeconds           = D_CurrentCount / D_CountFrequency;
        D_PercentTime           = (D_CurrentCount - (I_TimeSeconds * D_CountFrequency)) / D_CountFrequency;

        D_BoxHeight             = (sin(D_PercentTime*6.28318-3.14159))*50;

        CUSTOMVERTEX triangleVertices[] =
        {
                {640.0f, 480.0f+D_BoxHeight, 0.0f, 1.0f, 1.0f, 1.0f},
                {0.0f,   480.0f+D_BoxHeight, 0.0f, 1.0f, 0.0f, 1.0f},
                {0.0f,     0.0f+D_BoxHeight, 0.0f, 1.0f, 0.0f, 0.0f},

                {640.0f, 480.0f+D_BoxHeight, 0.0f, 1.0f, 1.0f, 1.0f},
                {0.0f,     0.0f+D_BoxHeight, 0.0f, 1.0f, 0.0f, 0.0f},
                {640.0f,   0.0f+D_BoxHeight, 0.0f, 1.0f, 1.0f, 0.0f},

        };

        IDirect3DVertexBuffer9* pVertexBuf = NULL;
        HRESULT hResult = g_pDirect3DDevice->CreateVertexBuffer(9*sizeof(CUSTOMVERTEX), 0, D3DFVF_XYZRHW | D3DFVF_TEX1, D3DPOOL_DEFAULT, &pVertexBuf, NULL);

        VOID* pVertices;
        hResult = pVertexBuf->Lock(0,0,(void**)&pVertices,0);
        memcpy(pVertices, triangleVertices, sizeof(triangleVertices));
        pVertexBuf->Unlock();

        g_pDirect3DDevice->Clear(0,NULL,D3DCLEAR_TARGET,
                D3DCOLOR_XRGB(25,100,150), 1.0f, 0);
        g_pDirect3DDevice->SetStreamSource(0, pVertexBuf,0, sizeof(CUSTOMVERTEX));
        g_pDirect3DDevice->SetTexture(0, g_pTexture);
        g_pDirect3DDevice->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1);
        g_pDirect3DDevice->BeginScene();
        g_pDirect3DDevice->DrawPrimitive(D3DPT_TRIANGLELIST,0,2);
        g_pDirect3DDevice->EndScene();
        g_pDirect3DDevice->Present(NULL,NULL,NULL,NULL);
}


Thanks for all your help guys

Share this post


Link to post
Share on other sites
I have the same problem. Are you running fullscreen? I only get a freeze when running fullscreen (no glut or simething, just windows.h) . Haven't found a solution though, but maybe this is the problem and not DirectX.

Greetings.

Share this post


Link to post
Share on other sites
The first thing that came to my mind was that you are not cleaning up some memory you are allocating per frame, whether it be via Direct3D or not. I suggest that you turn on D3D Debugging via the DirectX Control Panel icon and then come back with the output display when the applications is run.

You can also bring the task manager up before you run it, run the program, whilst watching the memory allocated to the process to see if it is sucking up your system.

Hope that helps,

Dave

Share this post


Link to post
Share on other sites
From first glance that tutorial has a massive memory leak, you're creating a new vertex buffer and not freeing it when you're done with it. Best solution is to create it once with a load method and use it to render multiple times.

Not only that but you're probably looping the render method, which will constantly leak more memory.

Share this post


Link to post
Share on other sites
I guess it was my fault... I had been cherry picking code out of the sections they listed.


the code they listed in that section had the vertex buffer seperate (the previous section had it in the render code)

guess i should have read it closer

Share this post


Link to post
Share on other sites

This topic is 4136 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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