title: How can I debug this StackOverflowException in my WinForm application?
body: <p>I have a winform application. Every few seconds I check some log files, read in any new data and insert any new data into a DB.</p>
  <p>When I run the application for around an hour 1/2, I get a <code>StackOverflowException</code>. There was no new data in the log files for that entire period, so nothing new was added to the DB.</p>
  <p>The code errored here...</p>
  <pre><code>if (pictureBox == null)
  {
      continue;
  }
  
  if (pictureBox.InvokeRequired)
  {
      var toolTip = new ToolTip();
      GameServer tempGameFile = gameServer;
      pictureBox.Invoke(new MethodInvoker(
          () =&gt; toolTip.SetToolTip(pictureBox,
              string.Format(
                  &quot;{0} : Last Checked: {1}; Last Updated: {2}&quot;,
                  tempGameFile.Name,
                  tempGameFile.CheckedOn.ToLongTimeString(),
                  tempGameFile.UpdatedOn.HasValue
                      ?
                          tempGameFile.UpdatedOn.Value.ToLongTimeString()
                          : &quot;-No Date Set-&quot;))));
  }
  pictureBox.Image = Resources.RedButton;
  </code></pre>
  <p>and the <code>pictureBox.Invoke(..)</code> is throwing that error.</p>
  <p>So .. i'm not sure how I can bebug this to figure out what is going on? Any suggestions?</p>
  <h3>UPDATE</h3>
  <p>Trying the suggestions of <a href="https://stackoverflow.com/users/625332/dmitry">Dmitry</a> I've started an ANTS profiler memory profile .. and having a quick look at things .. there seems to be a lot of instances of ToolTip controls.</p>
  <p>This is a class list summary after 20 mins.</p>
  <p><img src="https://i.stack.imgur.com/RJm8I.png" alt="enter image description here" /></p>
  <p>Lots of EventHandlers (am I not releasing something?)</p>
  <p>And there's a few ToolTips also...</p>
  <p><a href="https://i.imgur.com/LhpX0.png" rel="nofollow noreferrer">Here is a screenshot</a> of all the instances and <a href="https://imgur.com/ZkBcD" rel="nofollow noreferrer">here is a screenshot</a> of a single ToolTip control graph/map .. which I don't know how to read <em>blush</em></p>