.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Does Dictionary adjust initial Capacity to a quantum value

Posted By:      Posted Date: October 24, 2010    Points: 0   Category :.NET Framework

Dictionary<K, V> will automatically resize when needed. Presumably, the Capacity values it uses are in monotically increasing values determined by some algorithm, and thus one can assume that all dictionaries size up on these boundaries. Our system uses lots of Dictionaries, some of which get quite large and end up in the Large Object Heap. But because they all currently grow from 0, I assume (based on memory profiling) that I am allocating always exact sized chunks from LOH. so in practice, this never leads to a seriously fragmented LOH because all the allocated blocks are exact even multiples of some basic value.

I want to enhance the system by using the initial Capacity constructor based on an estimated capacity. But my big worry is that it will allocate that exact amount, and that this will therefore lead to serious fragmentation of the heap. List<V> provides an explicit Capacity property, so I could experiment with that collection to determine its behavior, but Dictionary does not provide any access to its current capacity. Does anyone know about this? Basically I want to know if when I request the initial Capacity in the ctor, will it actually round that up to one of its magic values that I would have hit had I increased its contents one by one; or is it going to just request that exact amount of capacity?

View Complete Post

More Related Resource Links

Thinking about new C# method prototypes: object as dictionary

I recently had to write a small Flickr API. I know many .Net API for Flickr already exist but I needed one for a Silverlight application. Whatever, it's only about building some querystrings so I did it by myself. It's been an opportunity to think again about a classical question: how to pass parameters to a method ?

Imagine you have a generic method to call some Flickr functions.

Mobile Apps: Adjust Your Ring Volume For Ambient Noise


Here's an overview of designing and installing a Windows Mobile app that monitors the noise level in the surrounding environment and adjusts the ring volume of a Pocket PC accordingly.

Chris Mitchell

MSDN Magazine October 2007

UpdatePanel - UpdateProgress only displays on initial postback



I'm having a somewhat odd issue, I'll do my best to explain it.

In a nutshell I have an UpdatePanel with an UpdateProgress item, first postback checks for warnings, if there are any they will be be displayed to the user as a JavaScript 'confirm' box. If the user clicks OK the next postback occurs to commit the change.

The UpdateProgress loading notification appears on the first postback but not on the second, even though both of them function correctly.  The buttons that trigger both postbacks are async postback triggers in the update panel, and both are inside the ContentTemplate.

It's not a huge problem, but it causes some confusion, has anybody ever seen this issue before?


Error Executing CLR Stored Procedure "Item has already been added. Key in dictionary"

Hello, I'm consuming a web service through assemblies in a Sql Server 2005 database. The client was made with VB.net 2005. Everything was fine in the deploy phase but once I compile the assembly generated in my sql server database and try to execute the CLR stored procedure defined in the assembly it crashes throwing the following error: Error: There was an error generating the XML document. Inner Exception: Item has already been added. Key in dictionary: 'SqlCifin.InfoComercial.ParametrosConsultaDTO' Key being added: 'SqlCifin.InfoComercial.ParametrosConsultaDTO' Where SqlCifin is the name of the assembly, InfoComercial is the web reference namespace and ParametrosConsultaDTO is a complex type defined in the WSDL to encapsulate the request parameters. I tried almost everything but nothing seems to work: Already checked the enviroment variables and . I would appreciate any help you can provide me.  PD: I'm using WSE 3.0. Thanks, Andres Diab.

Initial Value for Gridview where statement

I have an web page that has a calendar on it and a gridview that is supposed to use that calendar to grab entries from the database that match the date on the calendar.  How to I get the gridview to use the inital value of the calendar (before a change is made to it) - this is typically the current date? I currently have configured the gridview to use the SelectedValue from the Calendar. Is there a command to tell the gridview to refresh? Also is there a command to have the calendar pass the whole week that the date selected falls in? -eric

Why can't I load an an external resource dictionary that contains type converters?

Basically what I'm doing is putting a bunch of type converters as resources in a ResourceDictionary contained in an externally referenced assembly. Let's call the assembly WpfCommon. I'm directly referencing the assembly from my main application. In the App.xaml:       <Application.Resources>         <ResourceDictionary>             <ResourceDictionary.MergedDictionaries>                 <ResourceDictionary Source="pack://application:,,,/Common.Wpf;component/Wpf/ResourceDictionaries/Converters/Converters.xaml"/>             </ResourceDictionary.MergedDictionaries>         </ResourceDictionary>     </Application.Resources>   Converters.xaml:   <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"     xmlns:Common_Wpf_Converters="clr-namespace:Common.Wpf.Converters">     <ResourceDictionary>         <Common_Wpf_Convert

CLR Stored Procedures with WSE - Error "Item has already been added. Key in dictionary"

Hi, I'm developing a CLR Stored Procedure that consumes a Third party Web Service with WSE 3.0 (Due to WS Owners). Everything was fine in the Visual Studio Framework, but once I deploy the assemblies in my database and try to call the service from a query windows, it shows an error message:  Error: There was an error generating the XML document. Inner Exception: Item has already been added. Key in dictionary: 'SqlCifin.InfoComercial.ParametrosConsultaDTO' Key being added: 'SqlCifin.InfoComercial.ParametrosConsultaDTO' Stack Trace: at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id) at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle) at System.Web.Services.Protocols.SoapHttpClientProtocol.Serialize(SoapClientMessage message) at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) at SqlCifin.InfoComercial.InformacionComercialWSServiceWse.consultaXml(ParametrosConsultaDTO parametrosConsulta) at SqlCifin.StoredProcedures.sp_consultaXml(SqlString i_cod_info, SqlString i_motivo, SqlString i_ced_ruc, SqlString i_tipo_ced, SqlXml& o_xml)   I think it has to be something with the WSE but not completely sure. I really need to go t

The given key was not present in the dictionary.

When i click site columns in Site Settings. I got an error message.  The given key was not present in the dictionary.

Search Autocomplete: The given key was not present in the dictionary

Hello there! I am having difficulty with my search autocomplete. Below is all the code and error logs. Why am i getting "The given key is not present in the dictionary" when i try accessing the ashx file / searching? Can't seem to find the answer....   AutoCompletePeople.ashx (placed in the _layouts) folder <%@ WebHandler Language="C#" Class="GenericHandler1" %> <%@ Assembly Name="Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Assembly Name="Microsoft.Office.Server.Search, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Assembly Name="Microsoft.Office.Server, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> using System; using System.Web; using System.Data; using Microsoft.SharePoint; using Microsoft.Office.Server.Search.Query; public class GenericHandler1 : IHttpHandler { public void ProcessRequest (HttpContext context) { context.Response.ContentType = "text/plain"; string prefixText = context.Request["q"]; using (SPSite siteCollection = SPContext.Current.Site) { // create a new FullTextSqlQuery class FullTextSqlQuery query = new FullTextSqlQuery(siteCollection); query.QueryText = "SELECT Title FROM SCOPE() WHERE

SharePoint Capacity Planning Tool and system Center Capacity Planner

Hi, It seems like we cannot use the SharePoint Capacity Planning Tool anymore. I downloaded this SharePoint Capacity Planning Tool but its prerequisite system Center Capacity Planner(SCCP 2007) has been discontinued, as per this URL, http://technet.microsoft.com/en-us/systemcenter/ff575746.aspx  So when I try to install SharePoint Capacity Planning tool, it ask me to install SCCP V2 first. Please share if somebidy has a copy SCCP V2 or do we have any other alternate tool that can be used for SharePoint Capacity planning? Thanks, San      

Login error - No process is on the other end of the pipe on initial logon attempt

I am having a logon problem with asp.net apps that were created using Visual Web Developer 2008.  Data is on SQL Server Express 2008 running on Windows 2003 server with IIS6.  Connection is on a LAN.  The first time I try to log in to the site, I get the following error:Server Error in '/' Application.A connection was successfully established with the server, but then an error occurred during the login process. (provider: Named Pipes Provider, error: 0 - No process is on the other end of the pipe.)Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.Exception Details: System.Data.SqlClient.SqlException: A connection was successfully established with the server, but then an error occurred during the login process. (provider: Named Pipes Provider, error: 0 - No process is on the other end of the pipe.)Source Error:An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.Stack Trace:[SqlException (0x80131904): A connection was successfully established with the server, but then an error occurred during the login process. (provider: Named Pipes Provider, error: 0 - No proce

Data dictionary for pl sql

can i get detail for it .

Difference between ComponentResourceKey and a URI dictionary reference?

Hi, Sorry if that title doesn't make sense. I'm learning WPF and looking for a way to declare brush resources (eventually styles) in a single place and use them throughout the application which will have the UI in several different class libraries. I have a class library project named Common that all of the UI class libraries can reference. The book I'm using says that the ComponentResourceKey markup extension is designed for this purpose in which you have to create a Themes folder containing a file named generic.xaml. I've found that I can also just create a resource dictionary named anything in my Common project and then merge it with each Window's resouce dictionary using pack uri syntax: <Window.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="pack://application:,,,/Common;component/OasisBrushes.xaml"/> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Window.Resources> What is the difference between the two approaches? Why be forced to use a specific path and file name when you can do it the second way? Additionally, is there a way to reference the resource globally for the class library project so that I don't have to put it in each window/control? Can a class library have an App.xaml? Thanks!

FAST Search for SharePoint Dictionary Compilation Job systematically failing

Hello guys, Did anyone run into this problem? I just configured a SP2010 test server to use a freshly installed FAST Search Server and this job, which is scheduled to run every minute, fails systematically... Any thoughts on what might causing this? Below is the message reported in the Application logs The Execute method of job definition Microsoft.Office.Server.Search.Administration.FSDictionaryManagementJobDefinition (ID ccc0e26a-ece9-4d49-ae10-5d46ef675c85) threw an exception. More information is included below. No elements matching the key 'contractType:Microsoft.SharePoint.Search.Extended.Administration.Service.LinguisticManagerService;name:http' were found in the configuration element collection. Thanks!

Stringbuilders default capacity

Stringbuilder's default capacity is 16 bytes according to my 70-536 ms press book. Now a char in .NET is 2 bytes so does that mean the default capacity of a stringbuilder is 8 chars?

Item has already been added. Key in dictionary: 'HelpLink.ProdVer' Key being added: 'HelpLink.Pro

Hi All, I am getting this error while putting files on remote server. Please suggest me what to do. Following is the stack trace. Void Add(System.Object, System.Object) Item has already been added. Key in dictionary: 'HelpLink.ProdVer' Key being added: 'HelpLink.ProdVer' System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException: Item has already been added. Key in dictionary: 'HelpLink.ProdVer' Key being added: 'HelpLink.ProdVer'    at System.Collections.ListDictionaryInternal.Add(Object key, Object value)    at Microsoft.SqlServer.Management.Smo.SmoException.Init()    at Microsoft.SqlServer.Management.Smo.FailedOperationException..ctor(SerializationInfo info, StreamingContext context)    --- End of inner exception stack trace --- Server stack trace:    at System.RuntimeMethodHandle._SerializationInvoke(Object target, SignatureStruct& declaringTypeSig, SerializationInfo info, StreamingContext context)    at System.Reflection.RuntimeConstructorInfo.SerializationInvoke(Object target, SerializationInfo info, StreamingContext context)    at System.Runtime.Serialization.ObjectManager.CompleteISerializableObject(Object obj, SerializationInfo info, StreamingContext context)    

Dictionary class in MVC

hello guys,I do have Dictionary<Guid, Menu> where Guid is ID and Menu is my model for view which contains different  propertiesthat is :public class Menu    {        [Required(ErrorMessage = "Name is Required")]        public string Name { get; set; }        [Required(ErrorMessage = "Description is Required")]        public string Description { get; set; }    }now i do have extension method in which thru services i m assigning value to it..extension method is like this :public static Dictionary<Guid, Menu> GetMenuCategoriesModel(this IRService irService, IMCService imcService, Guid rIdmy question is that i have view named "Index" and in that view i wanna display "name" and i am generating strongly typed view and i have to use Dictionary<Guid, Menu> as model , how do i access Menu's properties as i wanna display name on the page ???Please suggest me..Thanks in advance
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend