-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
71 lines (58 loc) · 2.17 KB
/
Program.cs
File metadata and controls
71 lines (58 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
using System;
using System.Diagnostics;
using MonoBrickFirmware.Display;
using MonoBrickFirmware.UserInput;
namespace BrickMemory
{
public static class Program
{
static int[] tst;
public static void Main (string[] args)
{
// http://msdn.microsoft.com/en-us/library/s80a75e5%28VS.80%29.aspx
// The number of bytes that the associated process has allocated
// that cannot be shared with other processes.
Process proc = Process.GetCurrentProcess();
LcdConsole.WriteLine("PrivateMemorySize {0:N0}", proc.PrivateMemorySize64);
// http://msdn.microsoft.com/en-us/library/system.gc.gettotalmemory.aspx
// A number that is the best available approximation of the number of
// bytes currently allocated in managed memory.
LcdConsole.WriteLine("GC.GetTotalMemory {0:N0}", GC.GetTotalMemory(false));
// http://mono-project.com/Mono_Performance_Counters
//OutPerformanceCounterValue("Process", "Virtual Bytes");
//OutPerformanceCounterValue("Process", "Private Bytes");
OutPerformanceCounterValue("Mono Memory", "Total Physical Memory");
//OutPerformanceCounterValue(".NET CLR Memory", "# Bytes in all Heaps");
EV3KeyPad.ReadKey ();
LcdConsole.Clear ();
var MBytes = 42;
var bytes = MBytes * 1024 * 1024;
var intsize = sizeof(int);
LcdConsole.WriteLine ("Allocate {0}Mb of memory.", MBytes);
LcdConsole.WriteLine ("Please wait...");
tst = new int[ bytes/intsize ];
MBytes = 0;
for (int i=0; i < bytes/intsize; i++)
{
tst[i] = i;
if ((i * intsize % (1024 * 1024)) == 0)
{
LcdConsole.WriteLine("{0} MBytes used", ++MBytes);
}
}
LcdConsole.WriteLine("Finished!");
LcdConsole.WriteLine("Bytes allocated: {0:N0}", GC.GetTotalMemory(false));
//EV3KeyPad.ReadKey ();
//PerformanceContersInfo.Display ();
EV3KeyPad.ReadKey ();
LcdConsole.WriteLine ("Memory deallocation.");
LcdConsole.WriteLine ("Please wait...");
}
private static void OutPerformanceCounterValue( string categoryName, string counterName)
{
var pc = new PerformanceCounter(categoryName, counterName);
LcdConsole.WriteLine("{0} ({1})", counterName, categoryName);
LcdConsole.WriteLine("{0:N0}", pc.RawValue);
}
}
}