Skip to content

Setting the Maximum value on a Trackbar to a very large number results in excessive memory usage #329

@NarryG

Description

@NarryG
  • .NET Core Version: 3.0 Preview1
  • Have you experienced this same bug with .NET Framework?: Yes

Problem description:
Setting the MaxValue on the Trackbar control to a very high number results in excessive ram usage (in the gigabytes for a very large number).

This appears to be because on initialization of the underlying windows control, the maximum is set before the tick mark frequency, resulting in it initializing excessive amounts of tickmarks, although I do not have the build configuration to verify this theory myself at this time as if I did, I would just verify and submit this as a PR.

SendMessage(NativeMethods.TBM_SETRANGEMAX, 0, maximum);
SendMessage(NativeMethods.TBM_SETTICFREQ, tickFrequency, 0);

Actual behavior:
Excessive ram is used (multiple gigabytes if compiled in x64)

Expected behavior:
A reasonable amount of ram is used (assuming you set tickmarks to a reasonable number).

Minimal repro:
Within a form

TrackBar tb = new TrackBar();
tb.TickFrequency = 0; //Ensure no tickmarks should be drawn
tb.Maximum = 1000000000;
this.Controls.Add(tb);

Metadata

Metadata

Assignees

Labels

🪲 bugProduct bug (most likely)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions