RE: Commons-beanutils

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

RE: Commons-beanutils

Brosnan, Michael

I just ran those tests using maven and it worked ok.

Has anyone else ran the tests on commons-beanutils using ant?

Thanks

Mike Brosnan

> _____________________________________________
> From: Brosnan, Michael  
> Sent: 02 October 2008 10:46
> To: 'Commons Users List'
> Subject: Commons-beanutils
>
>
>
> I'm running the unit tests of commons-beanutils 1.80 and it hangs at
>
>     [junit] Tests run: 10, Failures: 0, Errors: 0, Time elapsed: 0.247 sec
>     [junit] Running
> org.apache.commons.beanutils.memoryleaktests.MemoryLeakTestCase
>
> It's using 1 GB of memory on a solaris server and when I contol-c the
> build to stop it, the process doesn't get killed.
>
> I'm using JDK 1.5 and ANT 1.7
>
>
> Regards
>
>
> Mike Brosnan
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Commons-beanutils

Simon Kitching
It might be worth trying to run the tests using an explicit
  -Xmx
setting, eg "-Xmx256m"

This test is checking for memory leaks by allocating some objects that
should be garbage-collected then forcing garbage-collection. But
unfortunately there is no java api to force garbage collection. So the
test simply allocates more and more memory until the garbage-collector
*has* to run. However if the JVM has a *lot* of memory available to it,
then filling it up might take a very long time. Perhaps on this machine
maven forks a jvm instance with a reasonable max-memory setting while
ant does not?

Regards,
Simon

Brosnan, Michael schrieb:

> I just ran those tests using maven and it worked ok.
>
> Has anyone else ran the tests on commons-beanutils using ant?
>
> Thanks
>
> Mike Brosnan
>
>  
>> _____________________________________________
>> From: Brosnan, Michael  
>> Sent: 02 October 2008 10:46
>> To: 'Commons Users List'
>> Subject: Commons-beanutils
>>
>>
>>
>> I'm running the unit tests of commons-beanutils 1.80 and it hangs at
>>
>>     [junit] Tests run: 10, Failures: 0, Errors: 0, Time elapsed: 0.247 sec
>>     [junit] Running
>> org.apache.commons.beanutils.memoryleaktests.MemoryLeakTestCase
>>
>> It's using 1 GB of memory on a solaris server and when I contol-c the
>> build to stop it, the process doesn't get killed.
>>
>> I'm using JDK 1.5 and ANT 1.7
>>
>>
>> Regards
>>
>>
>> Mike Brosnan
>>
>>
>>    
>
>  


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: Commons-beanutils

Brosnan, Michael
In reply to this post by Brosnan, Michael
Thanks for the reply

I see that the maven pom file has this set to 25m

              <forkMode>pertest</forkMode>^M
              <!-- limit memory size see BEANUTILS-291 -->^M
              <argLine>-Xmx25M</argLine>^M
              <includes>^M

I tried to do the same with ant using this parameter in ANT_OPTS, but I
still have the same problem.

Is ANT_OPTS the correct way to set this value?

Regards

Mike.

-----Original Message-----
From: Simon Kitching [mailto:[hidden email]]
Sent: 02 October 2008 12:04
To: Commons Users List
Subject: Re: Commons-beanutils

It might be worth trying to run the tests using an explicit
  -Xmx
setting, eg "-Xmx256m"

This test is checking for memory leaks by allocating some objects that
should be garbage-collected then forcing garbage-collection. But
unfortunately there is no java api to force garbage collection. So the
test simply allocates more and more memory until the garbage-collector
*has* to run. However if the JVM has a *lot* of memory available to it,
then filling it up might take a very long time. Perhaps on this machine
maven forks a jvm instance with a reasonable max-memory setting while
ant does not?

Regards,
Simon

Brosnan, Michael schrieb:

> I just ran those tests using maven and it worked ok.
>
> Has anyone else ran the tests on commons-beanutils using ant?
>
> Thanks
>
> Mike Brosnan
>
>  
>> _____________________________________________
>> From: Brosnan, Michael  
>> Sent: 02 October 2008 10:46
>> To: 'Commons Users List'
>> Subject: Commons-beanutils
>>
>>
>>
>> I'm running the unit tests of commons-beanutils 1.80 and it hangs at
>>
>>     [junit] Tests run: 10, Failures: 0, Errors: 0, Time elapsed: 0.247
sec

>>     [junit] Running
>> org.apache.commons.beanutils.memoryleaktests.MemoryLeakTestCase
>>
>> It's using 1 GB of memory on a solaris server and when I contol-c the
>> build to stop it, the process doesn't get killed.
>>
>> I'm using JDK 1.5 and ANT 1.7
>>
>>
>> Regards
>>
>>
>> Mike Brosnan
>>
>>
>>    
>
>  


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]


Reply | Threaded
Open this post in threaded view
|

DBCP: forcing recycling of small portions of active connections

Cyrille Roy
Hi,

I am working with a big oracle cluster, and I would need to recycle
active connections when returned from the pool (even if none are
considered idle by the pool and would have otherwise be reallocated to
another connection request immediately), as to periodically force a
small portion connections to be recreated. This is to cope with a broken
load balancing issue on my Oracle cluster (that misassigns all
connection to a single db instance). It seems the DBCP does not by
default support this using the standard properties, so I tried the
following suggestions following the post at
http://commons.markmail.org/search/?q=list%3Aorg.apache.commons.user+dbcp+force+order%3Adate-backward#query:list%3Aorg.apache.commons.user%20dbcp%20force%20order%3Adate-backward+page:2+mid:2ib7bfpofjytpxpl+state:results 
below

As anybody a better solution for this? Would the code sample below work?
I.e. would Pool.invalidateObject() indeed close the underlying object,
and lack of call to Pool.returnObject() would indeed prevent the connect
from being served back by the pool (and won't create memory leak)?




    GenericObjectPool connectionPool = new GenericObjectPool(null) {
    private final Random m_random = new Random(System.currentTimeMillis());
   
                        public synchronized void returnObject(Object connection) throws Exception {
    int rResult = m_random.nextInt(99);

                        //Force 10% of the connection to recyle upon release from the pool
    boolean shouldDropConnection = (rResult <= 10);

    if (shouldDropConnection) {
    //Ask the driver to close the connection
    invalidateObject(connection);
   
    //And skip returning the object from the pool
    System.out.println("initOracleYamPool: Dropping " + System.identityHashCode(connection) +  connection);
    } else {
    System.out.println("initOracleYamPool: Returning to pool  " + System.identityHashCode(connection) + connection);
    //Normally return the object to the pool
    super.returnObject(connection);
   
    }
                        }
   
    };
    connectionPool.setMaxActive(85);
                connectionPool.setMaxIdle(-1);
               
               
               
    String url= ...
                String username=...
                String password=...
               
               
               
    ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(url, username, password);
                                                             //PoolableConnectionFactory(ConnectionFactory connFactory,
    //ObjectPool pool,
    //KeyedObjectPoolFactory stmtPoolFactory,
    //String validationQuery,
    //boolean defaultReadOnly,
    //boolean defaultAutoCommit)
    PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(connectionFactory,
    connectionPool,
    null, //stmtPoolFactory
    "select 1 from dual", //validationQuery
    false, //defaultReadOnly
    true); //defaultAutoCommit
   
    connectionPool.setFactory(poolableConnectionFactory);
    PoolingDataSource pds= new PoolingDataSource(connectionPool);




I was trying to follow sample configuration of the pool (for max size
and min) at
http://commons.apache.org/dbcp/apidocs/org/apache/commons/dbcp/package-summary.html 
but it seems the connections are dropped from the pool as soon as they
become idle (whereas I indeed had set the
"connectionPool.setMaxIdle(-1);" to a negative value to prevent idle
connection cleanup)

Thanks in advance for your help,
Cyrille



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]