I doubt there are numbers. As I say, the interning of Strings was based on
ancient superstition (pre-dating me, I'm pretty sure). It's my recollection
that in very early JVM's, string-compare was slow and it was recommended that
you intern strings that you planned to compare a lot.
On 2011-04-15, at 11:15, André Bargull wrote:
> According to this comment in ASTIdentifier, interning was used to lower
> memory consumption (heap memory) at the cost of increased memory used in
> PermGem. (Are there any numbers to prove it helped reducing memory usage?)
>
>> public void setName(String name) {
>> this.name = name.intern(); // to lower number of strings
>> this.hash = name.hashCode();
>> }
>
>
> Concerning CPU cycles, it's actually faster to avoid calling String#intern(),
> see the VisualVM snapshots at [1].
>
>
> [1] http://jira.openlaszlo.org/jira/browse/LPP-9833
>
>
> On 4/15/2011 5:06 PM, P T Withington wrote:
>> This comes from an ancient superstition that string compares were costing us
>> valuable CPU cycles. If modern Java does that better, feel free to remove
>> the interns.
>>
>> On 2011-04-14, at 21:19, Donald Anderson wrote:
>>
>>> Yes, I've noticed this, and thought we should get rid of all those interns.
>>>
>>> On Apr 14, 2011, at 8:44 PM, André Bargull wrote:
>>>
>>>> The compiler also (ab)uses String#intern(), and interned strings are
>>>> stored in the PermGen, too. For example every ASTIdentifier's name is
>>>> interned....
>>>>
>>>>
>>>>> It is definitely the case that Tomcat slowly fills PermGen on each
>>>>> undeploy/deploy. It's a longstanding problem that has to do with
>>>>> classloaders, as I recall. The solution is to restart Tomcat.
>>>>>
>>>>> On 2011-04-14, at 11:40, Raju Bitter wrote:
>>>>>
>>>>>> Thanks, Quirino. It's not the case, but maybe the undeploy/deploy of
>>>>>> the OpenLaszlo webapp is causing the problem. I've increased the
>>>>>> Tomcat PemGen case the JAVA_OPTS and will see if it happens again.
>>>>>>
>>>>>> On Thu, Apr 14, 2011 at 5:38 PM, Quirino Zagarese
>>>>>> <quirino.zagarese at gmail.com> wrote:
>>>>>>> Such problems may appear when adding new libs to the runtime, since
>>>>>>> permgen
>>>>>>> space should be used to allocate Class objects. Is this the case?
>>>>>>>
>>>>>>> Il giorno 14/apr/2011 17.32, "Raju Bitter"
>>>>>>> <r.bitter.mailinglists at googlemail.com> ha scritto:
>>>>>>>> Using OL trunk, I ran into this error a few times in the past week.
>>>>>>>> Has anyone else seen that?
>>>>>>>> org.openlaszlo.sc.CompilerError: tunit/line unknown: , in line: Error:
>>>>>>>> PermGen space
>>>>>>>>
>>>>>>>> Which of course is: java.lang.OutOfMemoryError: PermGen space
>>>>>>>> Restarting Tomcat of course solves the problem, but I don't think I've
>>>>>>>> seen that in the past.
>>>>>>>
>>>
>>>
>>> --
>>>
>>> Don Anderson
>>> Java/C/C++, Berkeley DB, systems consultant
>>>
>>> voice: 617-306-2057
>>> email: [email protected]
>>> www: http://www.ddanderson.com
>>> blog: http://libdb.wordpress.com
>>>
>>>
>>>
>>>
>>>
>>
>>