1
我們如何釋放內存使用ID3D11Device :: CreateBuffer(...)創建緩衝區時? 我的目標是防止內存泄漏。釋放內存
Microsoft::WRL::ComPtr<ID3D11Buffer> m_vertexBuffer;
m_vertices = new std::vector<PNTVertex>();
/*... fill m_vertices with vertices ...*/
D3D11_BUFFER_DESC bd = { 0 };
D3D11_SUBRESOURCE_DATA initData = { 0 };
bd.Usage = D3D11_USAGE_DEFAULT;
bd.ByteWidth = sizeof(PNTVertex)* m_verticesCount;
bd.BindFlags = D3D11_BIND_VERTEX_BUFFER;
bd.CPUAccessFlags = 0;
initData.pSysMem = m_vertices->data();
DX::ThrowIfFailed(
device->CreateBuffer(&bd, &initData, &m_vertexBuffer)
);
謝謝。