It is currently March 28th, 2024, 11:45 am

[Bug] Memory Leak in UsageMonitor... or Windows PerfMon?

Report bugs with the Rainmeter application and suggest features.
Post Reply
User avatar
SilverAzide
Rainmeter Sage
Posts: 2588
Joined: March 23rd, 2015, 5:26 pm
Contact:

[Bug] Memory Leak in UsageMonitor... or Windows PerfMon?

Post by SilverAzide »

Hello!

I hesitate to post this since 99% of the time these sorts of posts are baseless, but there seems to be a memory leak someplace. Unfortunately, I don't have a good way to point a developer at a particular point in the code, but I'm happy to help in any way that I can.

Typically when I run Rainmeter with my usual set of skins active, Rainmeter consumes roughly 35MB of RAM, and this remains very steady. However, when I add a skin that has many instances of UsageMonitor measures (a "top process" skin), the Rainmeter process slowly consumes memory. After about 8 hours, memory is about 70MB and slowly increasing. I have not had time to let this run for a very long time under different conditions, but at one point I did let Rainmeter run this skin continuously for 3 days; at that point RM was using several hundred megabytes of RAM and -- unfortunately at some point while I was not looking -- RM seems to have crashed or something, because it was completely gone (no error message). So I was not able to see any message or attach a debugger. I have not had time to try duplicating this, but the memory issue is easily replicated.

I know this info is probably of little help. In case it matters, this is happening on multiple machines, including a "clean" VirtualBox VM with nothing on it except Rainmeter.

4.2.0 beta r3064 64-bit (May 13 2018) - English (1033)
Windows 10 Pro 1803 64-bit (build 17134) - English (1033)
Path: C:\Program Files\Rainmeter\
SkinPath: C:\Users\xxx\Documents\Rainmeter\Skins\
SettingsPath: C:\Users\xxx\AppData\Roaming\Rainmeter\
IniFile: C:\Users\xxx\AppData\Roaming\Rainmeter\Rainmeter.ini

Finally, if it is of any value, I've attached the skin demonstrating the issue. I don't think this skin is doing anything too abnormal, no extra plugins or etc., but perhaps I'm doing something that is causing an issue.
Attachments
Top Process Meter - Gadgets Patch_4.1.0.rmskin
(686.83 KiB) Downloaded 118 times
User avatar
tjhrulz
Developer
Posts: 267
Joined: October 13th, 2016, 1:28 am
Location: Earth
Contact:

Re: [Bug] Memory Leak in UsageMonitor... or Windows PerfMon?

Post by tjhrulz »

I'll investigate this tonight, likely some thread is not terminating correctly.

Is the thread count going up over time?

Edit: I have replicated the memory leak on my machine, also the thread count did slightly increase but the memory did not grow in bursts though. No idea why that would be happening though so I use timer threads for everything and all locks are being properly freed, also VS tried to tell me my heap space was only 1.7MB which isn't even right normally.

Status: Confirmed, further investigation needed to find cause.
Last edited by tjhrulz on May 26th, 2018, 3:48 pm, edited 3 times in total.
User avatar
SilverAzide
Rainmeter Sage
Posts: 2588
Joined: March 23rd, 2015, 5:26 pm
Contact:

Re: [Bug] Memory Leak in UsageMonitor... or Windows PerfMon?

Post by SilverAzide »

tjhrulz wrote:I'll investigate this tonight, likely some thread is not terminating correctly.

Is the thread count going up over time?
I did not think to check that! I'll check it out also and let you know.

Update:
tjhrulz wrote:Status: Confirmed, further investigation needed to find cause.
Glad to hear you were able to replicate this! I did check the thread count per your suggestion. This isn't an extensive run, but:
At session start, Rainmeter was at 25 threads and 36 MB of RAM.
After 4 hours, 28 threads and 48 MB RAM.
After 7 hours, 30 threads and 56 MB RAM.
PC was fairly idle during this time, only light browsing and email. I tried not to touch anything in Rainmeter to make the instance as static as possible.
User avatar
tjhrulz
Developer
Posts: 267
Joined: October 13th, 2016, 1:28 am
Location: Earth
Contact:

Re: [Bug] Memory Leak in UsageMonitor... or Windows PerfMon?

Post by tjhrulz »

SilverAzide wrote:I did not think to check that! I'll check it out also and let you know.

Update:

Glad to hear you were able to replicate this! I did check the thread count per your suggestion. This isn't an extensive run, but:
At session start, Rainmeter was at 25 threads and 36 MB of RAM.
After 4 hours, 28 threads and 48 MB RAM.
After 7 hours, 30 threads and 56 MB RAM.
PC was fairly idle during this time, only light browsing and email. I tried not to touch anything in Rainmeter to make the instance as static as possible.
Lol the threads had nothing to do with it, since Marshal.StringToHGlobalUni allocates memory that must be manually freed and I never used a buffer for it every measures GetString would leak a very tiny amount of memory. :x


brb gonna go fix a memory leak I have in one of my other plugins now...
Post Reply