A
Agrael1
Guest
Hello, I was doing a File Dialog module for a graphics editor.
For it I used IFileDialog, wrapped around with a WRL::ComPtr<>
std::wstring VFileOpenDialog::GetFilePath()
{
HRESULT hr;
if (SUCCEEDED(pDialog->Show(NULL)))
{
Microsoft::WRL::ComPtr<IShellItem> psiResult;
if (SUCCEEDED(pDialog->GetResult(&psiResult)))
{
PWSTR pszFilePath = NULL;
if (SUCCEEDED(psiResult->GetDisplayName(SIGDN_FILESYSPATH, &pszFilePath)))
{
return pszFilePath;
}
}
}
return std::wstring();
}
After this chunk of code it has to pass a filename to a file stream, but I saw a large memory leak after this ends.
I did a full testing, replaced ComPtrs with regular Raw Pointers, but nothing is helping. If I don't launch this method my memory usage is at 3 Mb, but when this method finishes it raises up to 17-20Mb.
How do I overcome those leaks and free a memory?
Continue reading...
For it I used IFileDialog, wrapped around with a WRL::ComPtr<>
std::wstring VFileOpenDialog::GetFilePath()
{
HRESULT hr;
if (SUCCEEDED(pDialog->Show(NULL)))
{
Microsoft::WRL::ComPtr<IShellItem> psiResult;
if (SUCCEEDED(pDialog->GetResult(&psiResult)))
{
PWSTR pszFilePath = NULL;
if (SUCCEEDED(psiResult->GetDisplayName(SIGDN_FILESYSPATH, &pszFilePath)))
{
return pszFilePath;
}
}
}
return std::wstring();
}
After this chunk of code it has to pass a filename to a file stream, but I saw a large memory leak after this ends.
I did a full testing, replaced ComPtrs with regular Raw Pointers, but nothing is helping. If I don't launch this method my memory usage is at 3 Mb, but when this method finishes it raises up to 17-20Mb.
How do I overcome those leaks and free a memory?
Continue reading...