C
C#3w ago
Kiel

Questions/concerns about memory usage in my project

Apologies for the messy formatting, I created this post because of multiple concerns and/or observations while profiling it. The first part is that I'm not very familiar with how GC works or is expected to work. Clearly in the first screenshot the drops are caused by garbage collection, but I'm unsure what's causing the gradual rises in memory. Is this just normal behavior since it seems to always drop to around the same level each time GC runs? Second question: What could cause total memory usage to vary wildly over the duration of a project running? In my case, this is a Discord bot profiled by dotMemory over the course of >24 hours (second screenshot). It reached a peak of 4.91GB used, and now we're currently using 2GB and the lowest total memory used was about 1.3GB. Snapshots have not shown me anything extremely out of the ordinary, it's expected data to be in memory. The only confusing part is that there are large quantities of CancellationTokenSources (third screenshot), despite every instance of one wrapped within a using statement to ensure it was disposed of. I'm very new to disgnosing memory leaks and/or usage issues so if I'm expressing incorrect assumptions or missing anything extremely obvious, let me know. I can post screenshots of my snapshots or anything else that might be relevant if needed.
No description
No description
No description
2 Replies
ACiDCA7
ACiDCA73w ago
this is hard to answer since every application is and behaves different. some apps are stable memory wise others are volatile. what exactly is you discord bot doing? how many users is it serving? if its something that just reponds when written to on a small server gigabytes of junk in a matter of minutes is suspicious i dont have dotmemory currently on the pc im on, so cant tell exactly where to look but when you try to open snapshots there is also a button "allocations" or so, which shows how many instances where created over lifetime i would take a look there first and see if you can spot something that has some really high numbers compared to the rest your base memoryuasge seems kinda stable its just something that creates tons of instances of something and then gets collected
Want results from more Discord servers?
Add your server