jenkinsci/repo-plugin — pull request #11 by bjarkef (2012-11-14 06:59:05+00:00)
Title: Caching of identical ProjectState objects in memory

We where seeing around 3500k instances of ProjectState in memory on our Jenkins installation, many of them completely identical. This occurs because Jenkins (using xstream) deserializes each and every build in the history of each and every project in memory on start up. We have around 20 jobs using the repo-plugin (and we expect at least to have twice as much in the future), each having a history of up to 2000 builds. We collect statistics for the entire lifetime of the project, so we want to keep the entire build history around.

This pull request includes a patch to ProjectState which creates an in-memory cache of ProjectState, such that no two identical ProjectState objects are instantiated. This is possible because ProjectState is immutable, and thus it should not have any side-effects.

After applying the patch we are now down to around 2k instances of ProjectState, consuming a total of around 200kB of memory.