Context:
A GUI Tool built using Windows form is basically doing the following 4 things
- Fetch logs from a biometric device (by CZKEM interop service) in every 5 seconds (by Form.Timer)
- Save featured logs into the MySql database locally (by ADO)
- Make status changes in a file on the drive i.e HasSavedLogs (by StreamWriter)
- It has to keep running and show error logs if something goes wrong with the above process
It has been taken care of disposing of all the IDisposealbes like for file(streamWriter) and DB(MySqlConnection, MySqlDataAdapter, MySqlCommand) are taken care of by the
using statements
. I can't unsubscribe from the timer event as I have ensure process keep running.
The Problem:
With the passage of time, it starts to consume a lot of memory which can be seen in Task Manager, after 1 day of execution it starts to take more than 1 GB of RAM. I ran a DotTrace as a profiler tool to further dig down what is taking such large memory. That pointed out a spike in unmanaged memory. Which can be seen in the following snapshot. It's good DotTrace pointed out the issue but I need to find out who is taking up all this memory. I have shared the DotTrace snaps, can someone help me on this?