【发布时间】:2011-05-11 08:27:04
【问题描述】:
long b = GC.GetTotalMemory(true);
SortedDictionary<int, int> sd = new SortedDictionary<int, int>();
for (int i = 0; i < 10000; i++)
{
sd.Add(i, i+1);
}
long a = GC.GetTotalMemory(true);
Console.WriteLine((a - b));
int reference = sd[10];
输出(32 位):
280108
输出(64 位):
480248
单独存储整数(在数组中)大约需要 80000 个。
【问题讨论】:
-
因为它是一棵树。还有一个 SortedList 和一个恰好被排序的普通 List(确保将项目插入到正确的位置)
标签: c# memory-management sorteddictionary