GerbilSoft / rom-properties

ROM Properties Page shell extension
GNU General Public License v2.0
491 stars 36 forks source link

Excess ram usage after listing files. #395

Open MarkWolves opened 1 year ago

MarkWolves commented 1 year ago

By pressing F5 several times you can notice a non-returning increase in ram usage. The bug occurs in explorer. My Windows is 7 (updated since 2015-2023 - avoiding not using Windows 10).

GerbilSoft commented 1 year ago

I did manage to reproduce this on my Windows 7 VM, but I'm not sure what's causing it. MSVC doesn't seem to have as many useful memory leak tools as Linux environments (valgrind, heaptrack, etc).

I tried out MSVCRT's built-in memory allocation reporting, and it did find one leak in AesCAPI_NG (only used when handling files that have encryption).

https://learn.microsoft.com/en-us/cpp/c-runtime-library/find-memory-leaks-using-the-crt-library?view=msvc-170

I suspect that if the other leaks are in fact caused by rom-properties and aren't weird caching behavior in Explorer, it's likely a Windows resource leak and not something that can be detected by MSVCRT. Will look for resource leak tools next.

GerbilSoft commented 1 year ago

Found something using WinDbg's !htrace command.

https://ofekshilon.com/2014/07/08/debugging-handle-leaks/

Will post results once I'm done analyzing it.

GerbilSoft commented 1 year ago

...and it seems I've hit a roadblock. What I thought were leaks was actually WinDbg logging both file open and close. Tried another tool and it showed many known memory leaks in Windows components, but nothing in rom-properties.

I suspect it might be a problem with IExtractIcon using up too much memory, since Explorer isn't really designed for per-file icons. Disabling IExtractIcon will still allow for thumbnail previews. I'll look into doing this in rp-config and seeing if it helps with this problem.