3 Replies Latest reply on Jul 28, 2003 9:39 AM by Allen Walker

    CMP Memory Leak? OutOfMemoryError/PostgreSQL

    espeerb Newbie

      I'm using JBoss 3.2.1 with PostgreSQL 7.3.3. I'm having difficulty with OutOfMemoryErrors getting thrown. I've managed to reproduce the problem with a toy problem (source attached).

      I can call the createTest() method (via a jboss-net web service in my case but the same problem occurs using a more conventional web interface) about 45-60 times successfully - after which an OutOfMemoryError gets thrown. This happens when I read large amounts of data (in the order of 3000 rows containing short xml fragments as data) too. It appears that some resources are not being properly released. I'm not holding onto any resources in my code so this must be something inside jboss somewhere, right?

      Any ideas/suggestions? I'm going to try using the MySQL JDBC driver next to see if there's something wrong with the PostgreSQL driver I'm using... But short of that being the problem I'm at a bit of a loss... :(

      Thanks.

        • 1. Re: CMP Memory Leak? OutOfMemoryError/PostgreSQL
          Juha Lindfors Master

          The default cache limit is quite large (about 1000000 instances or so), what's the max heap on your JVM when you run JBoss?

          Do you ever remove the instances you create? Otherwise they will be kept in memory until you either reach the cache limit or your VM runs out of memory.

          • 2. Re: CMP Memory Leak? OutOfMemoryError/PostgreSQL
            espeerb Newbie

            Reducing the cache limit solves the problem (actually managed to figure it out before getting a reply - but thanks - you've confirmed it for me). Doesn't jboss make use of SoftReference's for caching ejb's? If not, why not given the following extract from the api docs:


            All soft references to softly-reachable objects are guaranteed to have been cleared before the virtual machine throws an OutOfMemoryError.


            Seems this would be a good solution to the problem. Currently you have to tune your cache size based on the size you expect things to get otherwise things go horribly wrong. Using soft references one would not have a need for a cache limit as the cached objects will be turfed as soon as memory is required. Right?

            • 3. Re: CMP Memory Leak? OutOfMemoryError/PostgreSQL
              Allen Walker Newbie

              What did you change the cache limit too? In standardjboss.xml there are many different container-configuration blocks.. the one that would seem most relevant is "Standard CMP EntityBean".

              thanks