You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tiles.apache.org by "Boudreau, Pierre" <Pi...@T4G.com> on 2011/03/01 14:22:43 UTC

Tiles Cache Memory Usage

Hi,

I'm new to this list, so please point me in the right direction if this isn't the place for this topic.

We are using Tiles 2.1.2 in our application and have noticed that it is consuming a large portion of the memory we have available on our servers.  While analyzing a heap dump, we found out that most of this memory is held by CachingLocaleUrlDefinitionDAO, which has a HashMap that holds a HashMap of all tiles definitions for each locale.  A separate copy of each definition is held for each locale even if they are not localized.  In the heap dump I looked at, we had 115 identical copies of the tiles definitions at an average of over 1 MB each.  This was using over 150 MB of RAM when we only really need over 1 MB since none of our definitions are localized.  Is there a way to configure Tiles to avoid this?  Has this been improved in newer versions?

Thanks,

Pierre

Re: Tiles Cache Memory Usage

Posted by Antonio Petrelli <an...@gmail.com>.
2011/3/1 Boudreau, Pierre <Pi...@t4g.com>:
> Thanks for the quick response Antonio.  I do have a quick and easy patch that works for our situation where we are not using Tiles for localization at all.  I added an init parameter to disable localization and only use NULL_LOCALE whenever definitions are requested from CachingLocaleUrlDefinitionDAO.

I think that a completely different DAO would be better.

>  It would be nice to get this into the next 2.1 release so that we don't have to maintain our own custom version of the source.

There won't be any 2.1.x release, only 2.2.x is maintained.

> I haven't checked if the same patch could be merged in to the trunk as it is, but it's a pretty small change so it probably could.  Shall I send the patch to you directly or is there a more appropriate place to send it?

Create a JIRA issue and attach it. We can discuss it in the issue itself:
https://issues.apache.org/jira/browse/TILES
However nothing prevents you from using a customized DAO for your
needs, given the correct configuration:
http://tiles.apache.org/2.1/framework/tutorial/configuration.html

> I also attempted a more complete solution that modified CachingLocaleUrlDefinitionDAO to cache the definitions for all locales more efficiently by using the same objects when the is no localization instead of creating and storing a new identical object for each of them.  It all looked good when unit testing it, but it didn't reduce the memory consumption when I ran it through our load tests and I couldn't figure out why...

You can post it as "non official" patch and discuss it, maybe at Tiles
Developers mailing list:
http://tiles.apache.org/mail-lists.html

Thanks
Antonio

RE: Tiles Cache Memory Usage

Posted by "Boudreau, Pierre" <Pi...@T4G.com>.
Thanks for the quick response Antonio.  I do have a quick and easy patch that works for our situation where we are not using Tiles for localization at all.  I added an init parameter to disable localization and only use NULL_LOCALE whenever definitions are requested from CachingLocaleUrlDefinitionDAO.  It would be nice to get this into the next 2.1 release so that we don't have to maintain our own custom version of the source.  I haven't checked if the same patch could be merged in to the trunk as it is, but it's a pretty small change so it probably could.  Shall I send the patch to you directly or is there a more appropriate place to send it?

I also attempted a more complete solution that modified CachingLocaleUrlDefinitionDAO to cache the definitions for all locales more efficiently by using the same objects when the is no localization instead of creating and storing a new identical object for each of them.  It all looked good when unit testing it, but it didn't reduce the memory consumption when I ran it through our load tests and I couldn't figure out why...

Pierre

-----Original Message-----
From: Antonio Petrelli [mailto:antonio.petrelli@gmail.com] 
Sent: March-01-11 9:54 AM
To: users@tiles.apache.org
Cc: Boudreau, Pierre
Subject: Re: Tiles Cache Memory Usage

2011/3/1 Boudreau, Pierre <Pi...@t4g.com>:
> We are using Tiles 2.1.2 in our application and have noticed that it is consuming a large portion of the memory we have available on our servers.  While analyzing a heap dump, we found out that most of this memory is held by CachingLocaleUrlDefinitionDAO, which has a HashMap that holds a HashMap of all tiles definitions for each locale.  A separate copy of each definition is held for each locale even if they are not localized.  In the heap dump I looked at, we had 115 identical copies of the tiles definitions at an average of over 1 MB each.  This was using over 150 MB of RAM when we only really need over 1 MB since none of our definitions are localized.  Is there a way to configure Tiles to avoid this?  Has this been improved in newer versions?

I am sorry, there is no improvement in this. The problem is that
CachingLocaleUrlDefinitionDAO caches, for each locale, the same
definition copies for faster performance.
It can be improved, but I cannot do it at present time. You can
prepare a patch though :-)

Antonio

Re: Tiles Cache Memory Usage

Posted by Antonio Petrelli <an...@gmail.com>.
2011/3/1 Boudreau, Pierre <Pi...@t4g.com>:
> We are using Tiles 2.1.2 in our application and have noticed that it is consuming a large portion of the memory we have available on our servers.  While analyzing a heap dump, we found out that most of this memory is held by CachingLocaleUrlDefinitionDAO, which has a HashMap that holds a HashMap of all tiles definitions for each locale.  A separate copy of each definition is held for each locale even if they are not localized.  In the heap dump I looked at, we had 115 identical copies of the tiles definitions at an average of over 1 MB each.  This was using over 150 MB of RAM when we only really need over 1 MB since none of our definitions are localized.  Is there a way to configure Tiles to avoid this?  Has this been improved in newer versions?

I am sorry, there is no improvement in this. The problem is that
CachingLocaleUrlDefinitionDAO caches, for each locale, the same
definition copies for faster performance.
It can be improved, but I cannot do it at present time. You can
prepare a patch though :-)

Antonio