I know that I have a memory leak. I am writing in C# using Winforms. Basically, my program has a lot of buttons. Every .01 seconds, the timer classes calls a function to take in gps data from a gps. Each time a button is pressed, it gets paired with the most recent gps point and they both get pushed to a database. I don't know where the leak is. Could it be with the event handlers? Each button has a += but never a -=. Or could it be with when I post the gps point to the gui? I am writing to the database with entity framework.
Thanks,
Jessi
EDIT:
I know it is a memory leak because when I go into task manager I see memory being used by my program going consistently up. Also, the timer doesn't fire as often the later it gets...goes from .01 seconds to about .5 seconds. In the auto generated code, each button is subscribed to (last line):
this.commentsGoButton.Location = new System.Drawing.Point(348, 23);
this.commentsGoButton.Name = "commentsGoButton";
this.commentsGoButton.Size = new System.Drawing.Size(67, 70);
this.commentsGoButton.TabIndex = 12;
this.commentsGoButton.Text = "Enter Comment";
this.commentsGoButton.UseVisualStyleBackColor = true;
this.commentsGoButton.Click += new System.EventHandler(this.commentsGoButton_Click);
Also, I am calling this function:
GPS gps1 = new GPS(Lat, Longi, Alt, Yaw, Pit, Rol);
info.takeInGPS(gps1);
str = Lat + " " + Longi + " " + Alt + " " + Yaw + " " + Pit + " " + Rol + " ";
gui.addToTextBox(str);
Where GPS is the class I am calling it from. GPS is the class that takes in the point from the GPS. It is called by the timer inside the GUI class. GPS passes it to info to pass to the database and the the GUI class to post it using:
public void addToTextBox(string s)
{
textBox.Text += s += "\r\n";
textBox.SelectionStart = textBox.TextLength; //scrolling stuff
textBox.ScrollToCaret();
}
Info does this:
public void takeInGPS(GPS g)
{
gps = g;
write(gps);
}
What 3rd party programs will point out WHERE the memory leak is? Could the fact that I am creating 100 new GPS objects a second be the issue? Aren't I overwriting them?