string-interning Questions

6

Solved

I want to know the process and internals of string interning specific to .NET Framework. Would also like to know the benefits of using interning and the scenarios/situations where we should use str...
Effluent asked 8/11, 2011 at 17:19

8

Solved

What is String Interning in Java, when I should use it, and why?
Citizenship asked 14/5, 2012 at 7:18

4

Solved

In Java, explicitly declared Strings are interned by the JVM, so that subsequent declarations of the same String results in two pointers to the same String instance, rather than two separate (but i...
Kuhn asked 16/7, 2013 at 14:49

14

Solved

According to String#intern(), intern method is supposed to return the String from the String pool if the String is found in String pool, otherwise a new string object will be added in String pool a...
Reef asked 6/12, 2009 at 11:50

6

Solved

The second ReferenceEquals call returns false. Why isn't the string in s4 interned? (I don't care about the advantages of StringBuilder over string concatenation.) string s1 = "tom"; string s2 = "...
Terminable asked 24/4, 2010 at 23:40

3

Solved

I have a large file which, in essence contains data like: Netherlands,Noord-holland,Amsterdam,FooStreet,1,...,... Netherlands,Noord-holland,Amsterdam,FooStreet,2,...,... Netherlands,Noord-holland,...
Fly asked 1/5, 2015 at 9:58

3

Solved

Consider: String s1 = new StringBuilder("Cattie").append(" & Doggie").toString(); System.out.println(s1.intern() == s1); // true why? System.out.println(s1 == "Cattie & Doggie"); // true a...
Bartram asked 13/3, 2019 at 6:50

2

Solved

I have a large dataset from an analytics provider. It arrives in JSON and I parse it into a hash, but due to the size of the set I'm ballooning to over a gig in memory usage. Almost everything st...
Ottava asked 29/4, 2013 at 22:42

1

The following codes has different results when run using JDK 8 and JDK 9. public static void main(String[] args) { String s = new String("1"); s.intern(); String s2 = "1"; S...
Denn asked 4/11, 2018 at 13:28

3

Solved

Do common JavaScript engines, such as V8 and WebKit's JavaScriptCore, use string interning for JavaScript strings? Or do they actually keep multiple instances of identical strings in memory?

4

Solved

https://godbolt.org/z/cyBiWY I can see two 'some' literals in assembler code generated by MSVC, but only one with clang and gcc. This leads to totally different results of code execution. static ...
Grosvenor asked 15/10, 2018 at 10:17

4

public static void main(String[] args) { String str1 = new StringBuilder("计算机").append("软件").toString(); System.out.println(str1.intern() == str1); String str2 = new StringBuffer("ja").append("v...
Atworth asked 14/8, 2015 at 1:25

4

Solved

Does Python have a pool of all strings and are they (strings) singletons there? More precise, in the following code, are one or two strings created in memory? a = str(num) b = str(num)
Boice asked 25/3, 2010 at 21:33

0

How can I test the differences in scenarios of using interpolated strings vs concatenating strings such as this example: String interpolation const string a = "I change per class or method"; stri...
Cuculiform asked 24/7, 2018 at 19:41

1

Solved

Below is the Javadoc comment for String.intern() method: *Returns a canonical representation for the string object. A pool of strings, initially empty, is maintained privately by the class Stri...
Tatia asked 24/4, 2018 at 11:19

4

Solved

I have tried below code: public class TestIntern { public static void main(String[] args) { char[] c1={'a','b','h','i'}; String s1 = new String(c1); s1.intern(); String s2="abhi"; System.out...
Czar asked 27/3, 2018 at 21:7

4

Solved

I am trying to understand string interning and why is doesn't seem to work in my example. The point of the example is to show Example 1 uses less (a lot less memory) as it should only have 10 strin...
Soche asked 24/3, 2010 at 9:43

11

Solved

The behavior of String literals is very confusing in the code below. I can understand line 1, line 2, and line 3 are true, but why is line 4 false? When I print the hashcode of both they are the ...
Finedrawn asked 24/5, 2013 at 6:41

11

I user sun jdk 1.5 ThreadPoolExecutor( 24, 24,60,TimeUnit.SECONDS, new LinkedBlockingQueue()). soemtime I use jdb tool to find the status of all threads in thread pool are " waiting in a monitor", ...
Rattigan asked 8/12, 2008 at 9:21

1

Solved

I'm trying to understand reference comparing in Java. Let's assume we have the following main code: public static void main (String args[]) { String str1 = "Love!"; String str2 = "Love!"; Stri...
Timbering asked 23/7, 2017 at 21:7

2

Solved

Question 1 String a1 = "I Love" + " Java"; String a2 = "I Love " + "Java"; System.out.println( a1 == a2 ); // true String b1 = "I Love"; b1 += " Java"; String b2 = "I Love "; b2 += "Java"; System...
Scenography asked 18/7, 2017 at 11:27

1

I know what string interning is, and why the following code behaves the way it does: var hello = "Hello"; var he_llo = "He" + "llo"; var b = ReferenceEquals(hello, he_llo); //true Or var hello ...
Aldershot asked 27/1, 2017 at 13:58

1

Solved

I am building a Python utility that will involve mapping integers to word strings, where many integers might map to the same string. From my understanding, Python interns short strings and most har...
Alatea asked 1/1, 2017 at 2:15

2

Solved

In an earlier version of Python (I don't remember which), calling gc.get_referrers on an arbitrary interned string could be used to obtain a reference to the interned dict, which could then be quer...
Elastin asked 14/10, 2016 at 9:3

1

All.I have a java code snippet like this: String a = new StringBuilder("app").append("le").toString(); System.out.println(a.intern() == a); String b = new StringBuilder("orange").toString(); S...
Madonnamadora asked 8/10, 2016 at 7:7

© 2022 - 2024 — McMap. All rights reserved.