© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•16mo ago•
6 replies
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
CancellationTokenSource
CancellationTokenSource
s (third screenshot), despite every instance of one wrapped within a
using
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.
image.png
image.png
image.png
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Strange memory usage in C# OpenTK project
C#CC# / help
17mo ago
Optimizing Memory Usage
C#CC# / help
4y ago
✅ Questions about casting
C#CC# / help
3y ago
❔ Questions about popups
C#CC# / help
3y ago