You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by "Alexander Veit (JIRA)" <de...@velocity.apache.org> on 2011/04/29 15:44:05 UTC

[jira] [Created] (VELOCITY-801) Velocity 1.7 uses string interning

Velocity 1.7 uses string interning
----------------------------------

                 Key: VELOCITY-801
                 URL: https://issues.apache.org/jira/browse/VELOCITY-801
             Project: Velocity
          Issue Type: Bug
          Components: Engine
    Affects Versions: 1.7.x
         Environment: n.a.
            Reporter: Alexander Veit
            Priority: Critical


String interning consumes memory that cannot be reclaimed by the java runtime even if the velocity runtime singleton is being discarded.

This is an issue for server applications that use Velocity (e.g. we have a software product that may use tens of thousands of Velocity files to create content dynamically).

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


[jira] [Commented] (VELOCITY-801) Velocity 1.7 uses string interning

Posted by "Vincent Massol (JIRA)" <de...@velocity.apache.org>.
    [ https://issues.apache.org/jira/browse/VELOCITY-801?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13027049#comment-13027049 ] 

Vincent Massol commented on VELOCITY-801:
-----------------------------------------

Is it true that interned string space cannot be reclaimed. This doc seems to say otherwise (see myth3): http://www.codeinstructions.com/2009/01/busting-javalangstringintern-myths.html

> Velocity 1.7 uses string interning
> ----------------------------------
>
>                 Key: VELOCITY-801
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-801
>             Project: Velocity
>          Issue Type: Bug
>          Components: Engine
>    Affects Versions: 1.7.x
>         Environment: n.a.
>            Reporter: Alexander Veit
>            Priority: Critical
>
> String interning consumes memory that cannot be reclaimed by the java runtime even if the velocity runtime singleton is being discarded.
> This is an issue for server applications that use Velocity (e.g. we have a software product that may use tens of thousands of Velocity files to create content dynamically).

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


[jira] [Commented] (VELOCITY-801) Velocity 1.7 uses string interning

Posted by "Christopher Schultz (JIRA)" <de...@velocity.apache.org>.
    [ https://issues.apache.org/jira/browse/VELOCITY-801?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13032081#comment-13032081 ] 

Christopher Schultz commented on VELOCITY-801:
----------------------------------------------

Alexander, one more comment:

If you are concerned about memory usage, consider /not/ using the singleton Velocity object. Instead, instantiate your own and then you always have the option of discarding it. If you use the singleton pattern that Velocity supports, you're right: the singleton will never be collected. Take control of your own objects and stop using the singleton. It will give you greater flexibility.

> Velocity 1.7 uses string interning
> ----------------------------------
>
>                 Key: VELOCITY-801
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-801
>             Project: Velocity
>          Issue Type: Bug
>          Components: Engine
>    Affects Versions: 1.7.x
>         Environment: n.a.
>            Reporter: Alexander Veit
>            Priority: Critical
>
> String interning consumes memory that cannot be reclaimed by the java runtime even if the velocity runtime singleton is being discarded.
> This is an issue for server applications that use Velocity (e.g. we have a software product that may use tens of thousands of Velocity files to create content dynamically).

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


[jira] [Commented] (VELOCITY-801) Velocity 1.7 uses string interning

Posted by "Christopher Schultz (JIRA)" <de...@velocity.apache.org>.
    [ https://issues.apache.org/jira/browse/VELOCITY-801?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13032077#comment-13032077 ] 

Christopher Schultz commented on VELOCITY-801:
----------------------------------------------

This is a relatively easy fix if String.intern is proven to be holding onto these references inappropriately for some reason: just provide a simple, local String interning mechanism that can be discarded when the instance of (for instance) the Velocity object is discarded.

I'm actually glad to see Velocity is interning strings, though :)


> Velocity 1.7 uses string interning
> ----------------------------------
>
>                 Key: VELOCITY-801
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-801
>             Project: Velocity
>          Issue Type: Bug
>          Components: Engine
>    Affects Versions: 1.7.x
>         Environment: n.a.
>            Reporter: Alexander Veit
>            Priority: Critical
>
> String interning consumes memory that cannot be reclaimed by the java runtime even if the velocity runtime singleton is being discarded.
> This is an issue for server applications that use Velocity (e.g. we have a software product that may use tens of thousands of Velocity files to create content dynamically).

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


[jira] [Commented] (VELOCITY-801) Velocity 1.7 uses string interning

Posted by "Nathan Bubna (JIRA)" <de...@velocity.apache.org>.
    [ https://issues.apache.org/jira/browse/VELOCITY-801?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13027071#comment-13027071 ] 

Nathan Bubna commented on VELOCITY-801:
---------------------------------------

Those cached templates are discarded if the RuntimeInstance is discarded.

Here's the bottom line on this.  No relevant changes are going to be made for this without a test that demonstrates the problem and thus allows us to confirm the benefit of whatever solution is proposed.  The use of string.intern() was added because it was demonstrated that it fixed some major performance issues.  It will not be removed unless it is A) demonstrated to be a problem, as claimed and B) a replacement solution is offered that does not simply restore our previous issues.

Also, since we are talking about a native method and deep JVM voodoo :), Alexander, it would be best if you included more environment info.  Most especially, the JDK version, as that may well be relevant.  Evidence/description of your application's particular symptom(s) would also be meaningful in supporting your diagnosis.

> Velocity 1.7 uses string interning
> ----------------------------------
>
>                 Key: VELOCITY-801
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-801
>             Project: Velocity
>          Issue Type: Bug
>          Components: Engine
>    Affects Versions: 1.7.x
>         Environment: n.a.
>            Reporter: Alexander Veit
>            Priority: Critical
>
> String interning consumes memory that cannot be reclaimed by the java runtime even if the velocity runtime singleton is being discarded.
> This is an issue for server applications that use Velocity (e.g. we have a software product that may use tens of thousands of Velocity files to create content dynamically).

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


[jira] [Commented] (VELOCITY-801) Velocity 1.7 uses string interning

Posted by "Sergiu Dumitriu (JIRA)" <de...@velocity.apache.org>.
    [ https://issues.apache.org/jira/browse/VELOCITY-801?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13027060#comment-13027060 ] 

Sergiu Dumitriu commented on VELOCITY-801:
------------------------------------------

myth3 has one important if: "the internalized strings are garbage collected *if* there are no more references to them", and, IIRC, Velocity also caches the parsed templates, which counts as existing references.

> Velocity 1.7 uses string interning
> ----------------------------------
>
>                 Key: VELOCITY-801
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-801
>             Project: Velocity
>          Issue Type: Bug
>          Components: Engine
>    Affects Versions: 1.7.x
>         Environment: n.a.
>            Reporter: Alexander Veit
>            Priority: Critical
>
> String interning consumes memory that cannot be reclaimed by the java runtime even if the velocity runtime singleton is being discarded.
> This is an issue for server applications that use Velocity (e.g. we have a software product that may use tens of thousands of Velocity files to create content dynamically).

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org