You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by "Claude Brisson (JIRA)" <ji...@apache.org> on 2016/07/22 13:29:20 UTC

[jira] [Resolved] (VELOCITY-841) Velocity 2.0 memory usage improvement (even 50+% smaller template memory usage)

     [ https://issues.apache.org/jira/browse/VELOCITY-841?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claude Brisson resolved VELOCITY-841.
-------------------------------------
       Resolution: Fixed
         Assignee: Claude Brisson
    Fix Version/s: 2.x

Applied (commit 1753788).
I preferred to make String interning a  configuration option, with the default set to true (better choice for memory, I suppose).

> Velocity 2.0 memory usage improvement (even 50+% smaller template memory usage)
> -------------------------------------------------------------------------------
>
>                 Key: VELOCITY-841
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-841
>             Project: Velocity
>          Issue Type: Improvement
>          Components: Engine
>    Affects Versions: 2.x
>            Reporter: Jarkko Viinamäki
>            Assignee: Claude Brisson
>             Fix For: 2.x
>
>         Attachments: VELOCITY-841.patch
>
>
> Here's a somewhat radical patch that does two fundamental changes:
> 1. Token objects returned by the Parser that are normally carried around by AST Nodes are dropped completely or for the most part for many node types. This should be ok since Token is an internal structure. Tokens are typically dropped after node init so line/column numbering and other features should still work.
> 2. Interpolated image class variable carried around by the ASTStringLiteral is no longer kept around.
> I ran some tests for large text intensive templates and according to Eclipse Memory Analyzer patched 2.0.0 version template memory consumption was 50-60% smaller than with Velocity 1.7. Analyzer also shows that there are some duplicate strings (e.g. #if) that could be avoided by adding some logic but I didn't do it yet.
> I also removed string interning from the code since there have been some reports with big memory consumption after running Velocity for a while.
> There's a test build if you want to try this out:
> http://www.sci.fi/~jviinama/velocity/memoryboost/velocity-engine-core-2.0.0-SNAPSHOT.jar
> Note that Velocity 2.0 handles macro parameters differently than 1.7 so 2.0 may not work as drop in replacement for your app which is designed to work with 1.7.
> It would be interesting to hear comments about this change and if the test build works for you. All Velocity tests pass but real life use will most probably reveal bugs or design goofs that I overlooked.
> PS. These changes are not limited to Velocity 2.0 so same logic could be applied to 1.7 to reduce memory consumption.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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