Re: Is it a good practice to use intern() in all ids ?

2010-09-26 Thread Jeremy Thomerson
>
> I wouldn't do that. You'll most likely run into performance issues.
> Duplicate strings should only arise with the use of new String(). Explicitly
> calling intern() could cause an unexpected amount of memory usage in
> PermGen.


I think you have this backwards.  As James mentioned on this thread, string
literals in your code are automatically interned, so there is no need to do
what he is asking, because it is done by the compiler.

http://download.oracle.com/javase/1.4.2/docs/api/java/lang/String.html#intern()


-- 
Jeremy Thomerson
http://www.wickettraining.com


Re: Is it a good practice to use intern() in all ids ?

2010-09-26 Thread Richard Frovarp

 On 9/25/2010 8:53 PM, smallufo wrote:

I am using a profiler to analyze an OOM heap-dump file , and find tons of
duplicated Strings .
These strings are mostly IDs of wicket components or PropertyModel's
expression ...
I wonder if it a good practice to "intern()" all these Strings ?

such as :

private final static String TIME_STR = "time".intern();
add(new Label(TIME_STR , foobar));



I wouldn't do that. You'll most likely run into performance issues. 
Duplicate strings should only arise with the use of new String(). 
Explicitly calling intern() could cause an unexpected amount of memory 
usage in PermGen.


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Is it a good practice to use intern() in all ids ?

2010-09-25 Thread James Carman
If you use literal strings, they will be interned automatically.

On Sat, Sep 25, 2010 at 9:53 PM, smallufo  wrote:
> I am using a profiler to analyze an OOM heap-dump file , and find tons of
> duplicated Strings .
> These strings are mostly IDs of wicket components or PropertyModel's
> expression ...
> I wonder if it a good practice to "intern()" all these Strings ?
>
> such as :
>
> private final static String TIME_STR = "time".intern();
> add(new Label(TIME_STR , foobar));
>

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Is it a good practice to use intern() in all ids ?

2010-09-25 Thread smallufo
I am using a profiler to analyze an OOM heap-dump file , and find tons of
duplicated Strings .
These strings are mostly IDs of wicket components or PropertyModel's
expression ...
I wonder if it a good practice to "intern()" all these Strings ?

such as :

private final static String TIME_STR = "time".intern();
add(new Label(TIME_STR , foobar));