myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stevan Malesevic (JIRA)" <>
Subject [jira] Created: (TRINIDAD-1247) has very poor performance
Date Fri, 03 Oct 2008 16:08:44 GMT has very
poor performance

                 Key: TRINIDAD-1247
             Project: MyFaces Trinidad
          Issue Type: Bug
            Reporter: Stevan Malesevic

Application we use makes a calls to
for each instance of particular component. So there is a couple of calls per request.
While looking at CPU and memory usage we noticed that a significant amount is spent in this
call. In terms of memory for 45 invocations of this method 5802KB of memory is allocated ,
which means about 129K per method invocation

Most of this memory is spent creating Version objects in

To fix this issue we should change StyleSheetNode._compareBrowserAndVersion method to have
signature like
private int _compareBrowserAndVersion(int browser, TrinidadAgent agent)
and create Version object inside the method just before it is needed.   This will greatly
reduce the number of Version objects. 

The method looks like this:

  private int _compareBrowserAndVersion(int browser, TrinidadAgent agent)
    // If we don't have a browser specified, we match anything
    if (_agentVersions.isEmpty())

    // On the other hand, if we do have a browser specified, but
    // the client browser is not known, we don't have a match
    if (browser == TrinidadAgent.APPLICATION_UNKNOWN)
      return 0;
    //If we have browser exact match, compare versions
    Integer browserNum = Integer.valueOf(browser);
    if (_agentVersions.containsKey(browserNum))
      Set<Version> versions = _agentVersions.get(browserNum);
      if (versions.isEmpty())
      Version version = new Version(agent.getAgentVersion());
      for (Version av : versions)
        if (av.compareTo(version) == 0)
      return 0;

    return 0;

In my test case memory went down to 214K

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message