Tag Archives: memory

Display memory usage in C#

This program displays the computer’s total and free physical, virtual, and page file memory usage. When it starts, the following code displays the system’s memory information in the program’s ListView control. // Prepare the ListView and display values. private void … Continue reading

Posted in memory, programs | Tagged , , , , , , , , , , , | Leave a comment

Get the program’s memory usage in C#

This example uses the following code to display information about its memory usage. // Display information about the current process’s memory usage. private void Form1_Load(object sender, EventArgs e) { Process proc = Process.GetCurrentProcess(); AddItem(lvMemory, “Min Working Set”, ((double)proc.MinWorkingSet).ToFileSize()); AddItem(lvMemory, “Max … Continue reading

Posted in memory, programs | Tagged , , , , , , , , | Leave a comment

Force garbage collection in C#

This example shows how you can force garbage collection in C#. The .NET languages use a garbage collection scheme of memory management. There are a few weird details, but the basic process is this. When the application is running low … Continue reading

Posted in memory, system | Tagged , , , , , , , , , , , , , | Leave a comment

Build a formatted XML document in memory in C#

This example uses an XmlTextWriter to build a formatted XML document in memory and displays it in a text box. When you click the Go button, the following code executes. private void btnGo_Click(object sender, EventArgs e) { MemoryStream memory_stream = … Continue reading

Posted in XML | Tagged , , , , , , , , , , , , , , | 1 Comment