Re: runtime.parser.Parser maintains multiple VelocityCharStreams?

Nathan Bubna <[email protected]>
Newsgroups gmane.comp.jakarta.velocity.user
Message-ID <CAFyaDjEaiyUgSTdUid3eobBOV216G5sSi=SfD1My9EPhihYMSA@mail.gmail.com>
I've no idea.  I've never really dug into those much.  If Jarkko is
kicking around, he might know.

On Fri, Apr 12, 2013 at 10:41 AM, Christopher Schultz
<[email protected]> wrote:
> All,
>
> I've been doing some profiling looking for wasted memory in my webapp
> and I've discovered that org.apache.velocity.runtime.parser.Parser
> contains a few members that appear to be (essentially) duplicates.
>
> First, there is the "velocharstream" member which is a
> VelocityCharStream. Then, there is also a token_source member which is a
> ParserTokenManager which has a separate VelocityCharStream
> ("velcharstream" member). YourKit reports that these two are distinct
> objects, and they don't appear to share anything so I think they really
> are distinct.
>
> Each VelocityCharStream has a pair of 4096-byte buffers ("bufcolumn" and
> "bufline") plus a 8192-byte buffer in the "inputStream" member (a
> java.io.InputStreamReader), so each Parser is currently eating up 16k of
> memory in buffers. Yes, I know it's really nothing, but I'm wondering if
> buffers (or streams) are being allocated when they don't need to be
> allocated.
>
> Does anyone know why there might be two separate VelocityCharStreams at
> the Parser level? How about the 2 bufline/bufcolumn buffers in
> VelocityCharStream as well as the 8192-byte InputStreamReader buffer?
>
> The code has no inline documentation of Javadoc to suggest the purpose
> of these members.
>
> Thanks,
> -chris
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.