我在 Visual Studio 中有一个程序正在调试。它旨在测试计算机的内存(并且方便地命名为RAM......)。
在调试时,该程序的内存使用量不断增加。无论如何,我已经使用 Visual Studio 诊断工具来监控使用量。然而,直到最近,我才打开任务管理器来查看它的详细信息;我所看到的让我困惑。RAM 使用量明显低于诊断工具显示的值。
谁能告诉我为什么会发生这种情况?
提前致谢。
我正在将一个长字符串绘制到位图(通话超过一百万个字符),包括\r\n由a编写的多行字符StringBuilder。
我的文本到位图的代码如下:
public static Bitmap GetBitmap(string input, Font inputFont,
Color bmpForeground, Color bmpBackground) {
Image bmpText = new Bitmap(1, 1);
try {
// Create a graphics object from the image.
Graphics g = Graphics.FromImage(bmpText);
// Measure the size of the text when applied to image.
SizeF inputSize = g.MeasureString(input, inputFont);
// Create a new bitmap with the size of the text.
bmpText = new Bitmap((int)inputSize.Width,
(int)inputSize.Height);
// Instantiate graphics object, again, since our bitmap
// was …Run Code Online (Sandbox Code Playgroud)