microsoft / DirectML

DirectML is a high-performance, hardware-accelerated DirectX 12 library for machine learning. DirectML provides GPU acceleration for common machine learning tasks across a broad range of supported hardware and drivers, including all DirectX 12-capable GPUs from vendors such as AMD, Intel, NVIDIA, and Qualcomm.
MIT License
2.11k stars 284 forks source link

Memory Leak occurred when a for loop was add to the "HelloDirectML" Demo #85

Open laoniangjiu opened 3 years ago

laoniangjiu commented 3 years ago

Hi, When I add a for loop to the HelloDirectML demo to run the operator continuously,I found the memory usage continue to grow at the same time, seems like a memory leak.

main.zip

for (int i = 0; i != 1000; ++i) {
        commandList->SetDescriptorHeaps(ARRAYSIZE(d3D12DescriptorHeaps), d3D12DescriptorHeaps);

        dmlCommandRecorder->RecordDispatch(commandList.get(), dmlCompiledOperator.get(), dmlBindingTable.get());

        CloseExecuteResetWait(d3D12Device, commandQueue, commandAllocator, commandList);

        std::this_thread::sleep_for(std::chrono::milliseconds(30));
}
jstoecker commented 3 years ago

Thanks for reporting this. It's likely that the D3D command allocator is never reset in this sample, so it will grow unbounded. We'll fix it soon. :)

jstoecker commented 3 years ago

Should be fixed now.