[ 
https://issues.apache.org/jira/browse/TOMEE-1722?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15179609#comment-15179609
 ] 

Matthew Broadhead commented on TOMEE-1722:
------------------------------------------

on closer inspection the 4 threads that got stuck at 100% were ParallelGC.  The 
database was defined in global naming resources as

{code:xml}
<Resource auth="Container" driverClassName="com.mysql.jdbc.Driver"
                        maxActive="100" maxIdle="30" maxWait="10000" 
name="jdbc/MySQL"
                        password="password" type="javax.sql.DataSource"
                        
url="jdbc:mysql://localhost:3306/mysql?zeroDateTimeBehaviour=null"
                        username="root" />
{code}

i have changed it to 

{code:xml}
<Resource name="jdbc/MySQL" auth="Container" type="javax.sql.DataSource"
                        factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
                        testWhileIdle="true" testOnBorrow="true" 
testOnReturn="false"
                        validationQuery="SELECT 1" validationInterval="30000"
                        timeBetweenEvictionRunsMillis="30000" maxActive="100" 
minIdle="10"
                        maxWait="10000" initialSize="10" 
removeAbandonedTimeout="60"
                        removeAbandoned="true" logAbandoned="true"
                        minEvictableIdleTimeMillis="30000" jmxEnabled="true"
                        
jdbcInterceptors="org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;
            org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer"
                        username="root" password="password" 
driverClassName="com.mysql.jdbc.Driver"
                        
url="jdbc:mysql://localhost:3306/mysql?zeroDateTimeBehaviour=null" />
{code}

to see if it makes any difference.  the database is accessed using 

{code}
Context context = null;
                        Connection connection = null;
                        PreparedStatement preparedstatement = null;
                        ResultSet resultset = null;
                        try {
                                context = new InitialContext();
                                DataSource datasource = (DataSource) context
                                                
.lookup("java:comp/env/jdbc/MySQL");
                                connection = datasource.getConnection();
                                preparedstatement = 
connection.prepareStatement(temp,
                                                
Statement.RETURN_GENERATED_KEYS);
                                ....
                        } catch (SQLException e) {
                                e.printStackTrace();
                                key = -1;
                        } catch (NamingException e) {
                                e.printStackTrace();
                                key = -1;
                        } finally {
                                if (preparedstatement != null) {
                                        try {
                                                preparedstatement.close();
                                        } catch (SQLException e) {
                                                e.printStackTrace();
                                        }
                                }
                                if (connection != null) {
                                        try {
                                                connection.close();
                                        } catch (SQLException e) {
                                                e.printStackTrace();
                                        }
                                }
                                if (context != null) {
                                        try {
                                                context.close();
                                        } catch (NamingException e) {
                                                e.printStackTrace();
                                        }
                                }
                        }
{code}

it seems as if the memory usage is already creeping up from 900MB to 1.3GB 
overnight.  how many threads should TomEE usually have? it is currently 108 
threads

> Potential JMX memory leak
> -------------------------
>
>                 Key: TOMEE-1722
>                 URL: https://issues.apache.org/jira/browse/TOMEE-1722
>             Project: TomEE
>          Issue Type: Bug
>          Components: TomEE Core Server
>    Affects Versions: 1.7.2, 1.7.3
>            Reporter: Matthew Broadhead
>         Attachments: jstack-20160303-1604.txt
>
>
> I have been trying to track down a memory leak on a production server.  Was 
> 1.7.2 and is now 1.7.3.  I have run jvmtop and I get lots of threads with JMX 
> Server Connection Timeout.  I have searched my projects and I never use JMX 
> so is this something that is internal to TomEE?  I searched the error and it 
> said that whenever a JMXConnector is used the close() function must be called 
> at the end.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to