3

I am adding controls to a Windows Form during runtime in a C# .NET application. Each of these controls interacts with a particular signal and uses some data from that signal -- signal name, description, source, units, value, etc.

These controls have a check box on them. When the Visible property of the checkbox of just one of these signals becomes true, my application's Committed memory jumps over 800MB. None of the other hundreds of signals have the problem.

I used the DebugDiag tool to learn that comctl32.dll is allocating 805.45 MBytes. In particular:

  • Function comctl32_72380000!CCHeapAllocArraySize+3a
  • Allocation type Heap allocation(s)
  • Heap handle 0xf37893cd
  • Allocation Count 1 allocation(s)
  • Allocation Size 803.20 MBytes
  • Leak Probability 16%

What should be my next troubleshooting steps? What tools can help?

Update: I tracked the problem to a System.Windows.Forms.TrackBar on the parent control. The track bar had a maximum over 200,000,000. When I decreased the maximum to 100,000,000, it used about half the memory. Setting the maximum around 1,000,000 used a more reasonable amount of memory.

GreenRibbon
  • 299
  • 2
  • 16
  • Is there an actual problem or is this just a cosmetic issue? – David Schwartz Mar 04 '13 at 16:51
  • @DavidSchwartz: This is an actual problem. The application usually uses ~70MB of memory. Adding the control for this signal puts memory use around 900MB. This application is part of a real-time system simulation and the other applications in the system need this 800MB of memory. – GreenRibbon Mar 04 '13 at 17:09
  • 1
    Can you show a code sample that reproduces this issue? I'm assuming there's more to it than setting the CheckBox.Visible to true... – Pete Mar 04 '13 at 18:33
  • @Pete: I'm not sure if there's a good way to post a code sample. The line of code that triggers the memory use is just a `checkbox.Visible = true;`, but there must be more than that going on. I'm not sure a generic sample would reproduce the issue since this only happens for 1 of >100 controls, but I will look into that. – GreenRibbon Mar 04 '13 at 18:50
  • @Pete: I agree that the `checkbox.Visible = true` isn't the cause of the issue. I just noticed that sometimes the problem doesn't occur until the parent control is actually displayed (long after the Visible is set to true). – GreenRibbon Mar 04 '13 at 18:58

1 Answers1

0

I tracked the problem to a System.Windows.Forms.TrackBar on the parent control. The track bar had a maximum over 200,000,000. When I decreased the maximum to 100,000,000, it used about half the memory. Setting the maximum around 1,000,000 used a more reasonable amount of memory.

The checkbox.Visible threw me off. It appears that the applications was creating the control and the memory for it at the point the checkbox.Visible became true, but the checkbox itself had nothing to do with the problem.

GreenRibbon
  • 299
  • 2
  • 16