Red Gate forums :: View topic - String interning when string caching is disabled
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
SmartAssembly 6
SmartAssembly 6 forum

String interning when string caching is disabled

Search in SmartAssembly 6 forum
Post new topic   Reply to topic
Jump to:  
Author Message
BrettShearer



Joined: 24 Oct 2012
Posts: 3
Location: Australia

PostPosted: Wed Oct 24, 2012 1:17 am    Post subject: String interning when string caching is disabled Reply with quote

Hi - I assume that the following method is the code that extracts the encoded/compressed resource strings or strings in general.

I can see that this is interning the result string (str2). If this is the case, why is the static hashtable required.

public static string Get(int #05b)
{
#05b -= #Z5b;
if (#Y5b)
{
string str = (string) #z5b[#05b];
if (str != null)
{
return str;
}
}
int count = 0;
int index = #05b;
int num3 = #Xp[index++];
if ((num3 & 0x80) == 0)
{
count = num3;
if (count == 0)
{
return string.Empty;
}
}
else if ((num3 & 0x40) == 0)
{
count = ((num3 & 0x3f) << 8) + #Xp[index++];
}
else
{
count = ((((num3 & 0x1f) << 0x18) + (#Xp[index++] << 0x10)) + (#Xp[index++] << 8)) + #Xp[index++];
}
try
{
byte[] bytes = Convert.FromBase64String(Encoding.UTF8.GetString(#Xp, index, count));
string str2 = string.Intern(Encoding.UTF8.GetString(bytes, 0, bytes.Length));
if (#Y5b)
{
try
{
#z5b.Add(#05b, str2);
}
catch
{
}
}
return str2;
}
catch
{
return null;
}
}
Back to top
View user's profile Send private message AIM Address
james.billings



Joined: 16 Jun 2010
Posts: 1116
Location: My desk.

PostPosted: Thu Oct 25, 2012 3:42 pm    Post subject: Reply with quote

The hashtable is used to look up decoded strings to save decoding everything every time you reference one. The interning, I believe, just helps the performance of this.

Was there a specific reason you were asking?
Back to top
View user's profile Send private message
BrettShearer



Joined: 24 Oct 2012
Posts: 3
Location: Australia

PostPosted: Thu Oct 25, 2012 10:10 pm    Post subject: Reply with quote

Just checking as I have long running services where interning may take too much memory (I am hosting applications and have about 300 running on one machine). Interning may impact memory use for me.
Back to top
View user's profile Send private message AIM Address
james.billings



Joined: 16 Jun 2010
Posts: 1116
Location: My desk.

PostPosted: Fri Oct 26, 2012 7:58 am    Post subject: Reply with quote

Ah, okay- it's all related to the "I want to cache strings..." option so turning that off may be worth trying to see if it helps in your scenario.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group