C
Chris Vanstone
Guest
I have detected an extreme memory leak condition when using the set TextBox.Text property with MultiLine set to true in a C# application running on Windows 10.0.17763 (1809 update).
This has been causing crashes to desktop on my client systems for the last month where a communications logging text box would fail following a 20% purge operation.
Steps to replicate the issue:
- Generate a WinForm application with a TextBox set to MultiLine = true.
- Set the Text property to a string containing "\r\n" (i.e "a\r\n")
- Set the Text property to a string ending "\r" (i.e "a\r")
The application WorkingSet will ramp quickly to around 1GB and Commit to 1.2 to 2GB for around 30 to 60s. Following this, the app will recover, WorkingSet will reduce, but Commit memory remains allocated. Following2 or 3 instances of this issue, the app will crash to desktop, usually throwing a Stack Overflow exception.
A toggle of the MultiLine property between Text set operations appears to rectify this issue.
This cannot be replicated on any non-1809 updated machines.
Does the TextBox now cache the line feed method that it is first used with and then attempt to look for this if it is later updated with an incompatible one? i.e continue searching the heap for the missing "\n"?
private void breakLogButton_Click(object sender, EventArgs e)
{
logTextBox.Text = "a\r\n";
if (clearBeforeSetCheckBox.Checked)
{
// No effect
logTextBox.Clear();
}
if (resetMultiLineModeCheckBox.Checked)
{
// This will rectify the issue
logTextBox.Multiline = false;
logTextBox.Multiline = true;
}
logTextBox.Text = "a\r"; // Provided MultiLine has not been toggled, application will lock here for 30 to 60s
}
Continue reading...
This has been causing crashes to desktop on my client systems for the last month where a communications logging text box would fail following a 20% purge operation.
Steps to replicate the issue:
- Generate a WinForm application with a TextBox set to MultiLine = true.
- Set the Text property to a string containing "\r\n" (i.e "a\r\n")
- Set the Text property to a string ending "\r" (i.e "a\r")
The application WorkingSet will ramp quickly to around 1GB and Commit to 1.2 to 2GB for around 30 to 60s. Following this, the app will recover, WorkingSet will reduce, but Commit memory remains allocated. Following2 or 3 instances of this issue, the app will crash to desktop, usually throwing a Stack Overflow exception.
A toggle of the MultiLine property between Text set operations appears to rectify this issue.
This cannot be replicated on any non-1809 updated machines.
Does the TextBox now cache the line feed method that it is first used with and then attempt to look for this if it is later updated with an incompatible one? i.e continue searching the heap for the missing "\n"?
private void breakLogButton_Click(object sender, EventArgs e)
{
logTextBox.Text = "a\r\n";
if (clearBeforeSetCheckBox.Checked)
{
// No effect
logTextBox.Clear();
}
if (resetMultiLineModeCheckBox.Checked)
{
// This will rectify the issue
logTextBox.Multiline = false;
logTextBox.Multiline = true;
}
logTextBox.Text = "a\r"; // Provided MultiLine has not been toggled, application will lock here for 30 to 60s
}
Continue reading...