   how to release this to avoid memory leak??
  i set my direct3d control panel to break at memory leaksso this line come in the output windowMemory still allocated!  Alloc count = 162when i set the control panel to break at alloc idthe program break at this line[source lang = "cpp"] dw32BitFlag = ( pMesh->GetOptions() & D3DXMESH_32BIT );but i release the pMesh like that[source lang = "cpp"]pMesh->Release();if this is a false positivehow can i override it???   
  It's not a false positive, but I don't see how it could be breaking on that line. Are you sure it's not breaking on the line before / after?This usually means that there's something holding onto the mesh pointer, you'll need to find out what it is. Usually, I just comment out bits of code until it goes away, then you know what's causing it.   ;[source lang = "cpp"]LPD3DXBUFFER pD3DXMtrlBuffer = NULL;D3DXMATERIAL* d3dxMaterials;DWORD dw32BitFlag;LPD3DXMESH pMesh = NULL;LPD3DXPMESH pPMesh = NULL;LPD3DXBUFFER pAdjacencyBuffer = NULL;ID3DXPMesh** g_ppPMeshes = NULL;ID3DXPMesh*  g_pPMeshFull = NULL;LPD3DXMESH   pTempMesh;DWORD   g_cPMeshes = 0;DWORD   g_iPMeshCur;D3DMATERIAL9*g_mtrlMeshMaterials = NULL;LPDIRECT3DTEXTURE9*    g_ppMeshTextures = NULL;// Array of textures, entries are NULL if no texture specifiedDWORD   g_dwNumMaterials = 0;   // Number of materialsD3DXMATRIXA16g_mWorldCenter;D3DXVECTOR3  g_vObjectCenter;   // Center of bounding sphere of objectFLOAT   g_fObjectRadius;//////////////////void LoadPMesh1(void){    D3DXLoadMeshFromX("house.x", D3DXMESH_MANAGED, d3ddev,   &pAdjacencyBuffer, &pD3DXMtrlBuffer, NULL,   &g_dwNumMaterials, &pMesh);    dw32BitFlag = ( pMesh->GetOptions() & D3DXMESH_32BIT );   D3DXCleanMesh( D3DXCLEAN_SIMPLIFICATION, pMesh, ( DWORD* )pAdjacencyBuffer->GetBufferPointer(), &pTempMesh, ( DWORD* )pAdjacencyBuffer->GetBufferPointer(), NULL );    pMesh->Release();    pMesh = pTempMesh;    D3DXWELDEPSILONS Epsilons;    ZeroMemory( &Epsilons, sizeof( D3DXWELDEPSILONS ) );    D3DXWeldVertices( pMesh, 0, &Epsilons,    ( DWORD* )pAdjacencyBuffer->GetBufferPointer(),    ( DWORD* )pAdjacencyBuffer->GetBufferPointer(), NULL, NULL );  D3DXValidMesh( pMesh, ( DWORD* )pAdjacencyBuffer->GetBufferPointer(), NULL );   d3dxMaterials= ( D3DXMATERIAL* )pD3DXMtrlBuffer->GetBufferPointer();    g_mtrlMeshMaterials = new D3DMATERIAL9[g_dwNumMaterials];    g_ppMeshTextures = new LPDIRECT3DTEXTURE9[g_dwNumMaterials];   for( UINT i = 0; i < g_dwNumMaterials; i++ )    {   g_mtrlMeshMaterials = d3dxMaterials.MatD3D;   g_mtrlMeshMaterials.Ambient = g_mtrlMeshMaterials.Diffuse;   if( FAILED( D3DXCreateTextureFromFile( d3ddev,d3dxMaterials.pTextureFilename, &g_ppMeshTextures ) ) ){  g_ppMeshTextures = NULL;}    }    LPDIRECT3DVERTEXBUFFER9 pVertexBuffer = NULL;    void* pVertices;    pMesh->GetVertexBuffer( &pVertexBuffer );    pVertexBuffer->Lock( 0, 0, &pVertices, D3DLOCK_NOSYSLOCK );   D3DXComputeBoundingSphere( ( D3DXVECTOR3* )pVertices, pMesh->GetNumVertices(), D3DXGetFVFVertexSize( pMesh->GetFVF() ), &g_vObjectCenter, &g_fObjectRadius );    pVertexBuffer->Unlock();pVertexBuffer->Release(); {   D3DXMatrixTranslation( &g_mWorldCenter, -g_vObjectCenter.x, -g_vObjectCenter.y, -g_vObjectCenter.z );    D3DXMATRIXA16 m;   D3DXMatrixScaling( &m, 2.0f / g_fObjectRadius,  2.0f / g_fObjectRadius,  2.0f / g_fObjectRadius );   D3DXMatrixMultiply( &g_mWorldCenter, &g_mWorldCenter, &m );    }  // If the mesh is missing normals, generate them.    if( !( pMesh->GetFVF() & D3DFVF_NORMAL ) )    {  pMesh->CloneMeshFVF( dw32BitFlag | D3DXMESH_MANAGED, pMesh->GetFVF() | D3DFVF_NORMAL,    d3ddev, &pTempMesh );   D3DXComputeNormals( pTempMesh, NULL );   pMesh->Release();   pMesh = pTempMesh;    }    // Generate progressive meshes    D3DXGeneratePMesh( pMesh, ( DWORD* )pAdjacencyBuffer->GetBufferPointer(),   NULL, NULL, 1, D3DXMESHSIMP_VERTEX, &pPMesh );    DWORD cVerticesMin = pPMesh->GetMinVertices();    DWORD cVerticesMax = pPMesh->GetMaxVertices();    DWORD cVerticesPerMesh = ( cVerticesMax - cVerticesMin + 10 ) / 10;    g_cPMeshes = max( 1, ( DWORD )ceil( ( cVerticesMax - cVerticesMin + 1 ) / ( float )cVerticesPerMesh ) );    g_ppPMeshes = new LPD3DXPMESH[g_cPMeshes];    ZeroMemory( g_ppPMeshes, sizeof( LPD3DXPMESH ) * g_cPMeshes );    // Clone full size pmesh    pPMesh->ClonePMeshFVF( D3DXMESH_MANAGED | D3DXMESH_VB_SHARE, pPMesh->GetFVF(), d3ddev, &g_pPMeshFull );    // Clone all the separate pmeshes    for( UINT iPMesh = 0; iPMesh < g_cPMeshes; iPMesh++ )    {  pPMesh->ClonePMeshFVF( D3DXMESH_MANAGED | D3DXMESH_VB_SHARE, pPMesh->GetFVF(), d3ddev, &g_ppPMeshes[iPMesh] );   // Trim to appropriate space   g_ppPMeshes[iPMesh]->TrimByVertices( cVerticesMin + cVerticesPerMesh * iPMesh,cVerticesMin + cVerticesPerMesh * ( iPMesh + 1 ), NULL, NULL );   g_ppPMeshes[iPMesh]->OptimizeBaseLOD( D3DXMESHOPT_VERTEXCACHE, NULL );    }    // Set current to be maximum number of vertices    g_iPMeshCur = g_cPMeshes - 1;    g_ppPMeshes[g_iPMeshCur]->SetNumVertices( cVerticesMax );    pD3DXMtrlBuffer->Release();pAdjacencyBuffer->Release();    pAdjacencyBuffer = NULL;pPMesh->Release();pMesh->Release();   return;}///////////////void SetNumVertices( DWORD dwNumVertices ){    // If current pm valid for desired value, then set the number of vertices directly    if( ( dwNumVertices >= g_ppPMeshes[g_iPMeshCur]->GetMinVertices() ) &&   ( dwNumVertices <= g_ppPMeshes[g_iPMeshCur]->GetMaxVertices() ) )    {   g_ppPMeshes[g_iPMeshCur]->SetNumVertices( dwNumVertices );    }    else  // Search for the right one    {   g_iPMeshCur = g_cPMeshes - 1;   // Look for the correct "bin"   while( g_iPMeshCur > 0 )   {  // If number of vertices is less than current max then we found one to fit  if( dwNumVertices >= g_ppPMeshes[g_iPMeshCur]->GetMinVertices() ) break;  g_iPMeshCur -= 1;   }   // Set the vertices on the newly selected mesh   g_ppPMeshes[g_iPMeshCur]->SetNumVertices( dwNumVertices );    }return;}////////void DrawPMesh1(void){for(DWORD i = 0; i < g_dwNumMaterials; i++ ){d3ddev->SetMaterial(&g_mtrlMeshMaterials);d3ddev->SetTexture(0,g_ppMeshTextures);    g_ppPMeshes[g_iPMeshCur]->DrawSubset( i );}return;}//////////void PMRelease(void){for( UINT i = 0; i < g_dwNumMaterials; i++ ){if(g_ppMeshTextures != NULL){    g_ppMeshTextures->Release();}}delete[] g_ppMeshTextures;g_ppMeshTextures = NULL;g_pPMeshFull->Release();    for( UINT i = 0; i < g_cPMeshes; i++ ){g_ppPMeshes->Release();    g_cPMeshes = 0;    delete[] g_ppPMeshes;g_ppPMeshes = NULL;}    delete[] g_mtrlMeshMaterials;   g_dwNumMaterials = 0;return;} [Edited by - DiPharoH on April 30, 2009 11:26:53 AM];  It's probably the D3DXLoadMeshFromX() call that's causing the leak. All that means is that the mesh, or one of its buffers isn't being released.By reading through that code, the following resources have not been released:pAdjacencyBuffer, pMesh, pPMesh, g_pPMeshFull.   ;Quote:Original post by Evil SteveIt's probably the D3DXLoadMeshFromX() call that's causing the leak. All that means is that the mesh, or one of its buffers isn't being released.By reading through that code, the following resources have not been released:pAdjacencyBuffer, pMesh, pPMesh, g_pPMeshFull.i modified my codeplease check it;Quote:Original post by DiPharoHQuote:Original post by Evil SteveIt's probably the D3DXLoadMeshFromX() call that's causing the leak. All that means is that the mesh, or one of its buffers isn't being released.By reading through that code, the following resources have not been released:pAdjacencyBuffer, pMesh, pPMesh, g_pPMeshFull.i modified my codeplease check itpAdjacencyBuffer, pMesh and pPMesh are local variables, you can't access them from another function. You should be releasing them before the end of LoadPMesh1().   ;Quote:Original post by Evil SteveQuote:Original post by DiPharoHQuote:Original post by Evil SteveIt's probably the D3DXLoadMeshFromX() call that's causing the leak. All that means is that the mesh, or one of its buffers isn't being released.By reading through that code, the following resources have not been released:pAdjacencyBuffer, pMesh, pPMesh, g_pPMeshFull.i modified my codeplease check itpAdjacencyBuffer, pMesh and pPMesh are local variables, you can't access them from another function. You should be releasing them before the end of LoadPMesh1().i modified my code again check itbut i still cannot get iti am gonna get crazyohhhhhh no please help;  ohhhhhhhhhhhhhhhhhhohhhhhhhhhhhhhhhohhhhhhhhhhhhhhhi did iti donot know how but i just did ityooooooooyoooooooooyo