简体   繁体   English

有没有字典的替代品<key, value>在 C# 中分配非连续的 memory</key,>

[英]Is there any Alternative of Dictionary<Key, Value> with non contiguous memory allocation in C#

Using Dictionary<Key, Value> causing issues in memory allowing ( error Failed to allocate memory) in the application So is there any alternative which is allocate memory in non contiguous form.使用 Dictionary<Key, Value> 在 memory 中导致问题允许(错误无法分配内存)在应用程序中所以是否有任何替代方案以非连续形式分配 memory。

I tried with sortedList<Key, Value> collection but doesn't work out我尝试使用 sortedList<Key, Value> 集合但没有成功

Memory allocation will be based on the objects you add to the dictionary (or HashSet or SortedList, or any kind of list). Memory 分配将基于您添加到字典(或 HashSet 或 SortedList,或任何类型的列表)的对象。

If you want to keep fixed sized of items in your dictionary, you can pass the capacity for the dictionary when instantiating it.如果你想在你的字典中保持固定大小的项目,你可以在实例化它时传递字典的容量 Or you can use Stack<TItem> with capacity so you can push/pop.或者您可以将Stack<TItem>与 capacity 一起使用,这样您就可以推送/弹出。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM