String interning when string caching is disabled

.NET obfuscator and automated error reporting

Moderators: Luke Jefferson, melvyn.harbour, dom.smith

String interning when string caching is disabled

Postby BrettShearer » Wed Oct 24, 2012 1:17 am

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;
}
}
BrettShearer
 
Posts: 3
Joined: Wed Oct 24, 2012 12:44 am
Location: Australia

Postby james.billings » Thu Oct 25, 2012 3:42 pm

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?
james.billings
 
Posts: 1144
Joined: Wed Jun 16, 2010 11:10 am
Location: My desk.

Postby BrettShearer » Thu Oct 25, 2012 10:10 pm

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.
BrettShearer
 
Posts: 3
Joined: Wed Oct 24, 2012 12:44 am
Location: Australia

Postby james.billings » Fri Oct 26, 2012 7:58 am

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.
james.billings
 
Posts: 1144
Joined: Wed Jun 16, 2010 11:10 am
Location: My desk.


Return to SmartAssembly 6

Who is online

Users browsing this forum: No registered users and 0 guests