activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ilia Stepanov (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (AMQ-4487) java.lang.OutOfMemoryError: Java heap space
Date Mon, 03 Jun 2013 14:05:21 GMT

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

Ilia Stepanov commented on AMQ-4487:
------------------------------------

Please use following test case to reproduce the problem. The test case illustrates two problems:

- it is not possible to use Web Console (and QueueBrowser) if a queue contains messages from
more then *64* producers. The enumeration gives endless number of messages in the queue which
causes out of memory in case of the Web Console.
- it is not possible to increase this threshold of 64 via PolicyEntry (the value does not
get propagated properly to ActiveMQMessageAuditNoSync class). Check my comment 31/May/13 16:20
for a possible fix.


package org.apache.activemq.bugs;

import static org.junit.Assert.assertEquals;

import java.net.URI;
import java.util.Enumeration;

import javax.jms.Connection;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageProducer;
import javax.jms.QueueBrowser;
import javax.jms.Session;

import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.broker.TransportConnector;
import org.apache.activemq.broker.region.policy.PolicyEntry;
import org.apache.activemq.broker.region.policy.PolicyMap;
import org.apache.activemq.command.ActiveMQQueue;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author Ilya Stepanov
 */
public class AMQ4487Test {

	private static final Logger LOG = LoggerFactory
			.getLogger(AMQ4487Test.class);

	private BrokerService broker;
	private URI connectUri;
	private ActiveMQConnectionFactory factory;

	@Before
	public void startBroker() throws Exception {
		broker = new BrokerService();
		TransportConnector connector = broker.addConnector("tcp://0.0.0.0:0");
		broker.deleteAllMessages();
		broker.start();
		broker.waitUntilStarted();
		connectUri = connector.getConnectUri();
		factory = new ActiveMQConnectionFactory(connectUri);
	}

	@After
	public void stopBroker() throws Exception {
		broker.stop();
		broker.waitUntilStopped();
	}

	@Test
	public void testBrowsing() throws JMSException {

		PolicyEntry policy = new PolicyEntry();
		policy.setQueue(">");
		policy.setMaxProducersToAudit(400);
		PolicyMap pMap = new PolicyMap();
		pMap.setDefaultEntry(policy);
		broker.setDestinationPolicy(pMap);

		int messageToSend = 370;

		ActiveMQQueue queue = new ActiveMQQueue("TEST");
		Connection connection = factory.createConnection();
		connection.start();
		Session session = connection.createSession(false,
				Session.AUTO_ACKNOWLEDGE);

		String data = "";
		for (int i = 0; i < 1024 * 2; i++) {
			data += "x";
		}

		for (int i = 0; i < messageToSend; i++) {
			Connection msg_connection = factory.createConnection();
			msg_connection.start();
			Session msg_session = msg_connection.createSession(false,
					Session.AUTO_ACKNOWLEDGE);
			MessageProducer msg_producer = msg_session.createProducer(queue);
			msg_producer.send(msg_session.createTextMessage(data));
		}

		QueueBrowser browser = session.createBrowser(queue);
		Enumeration enumeration = browser.getEnumeration();
		int received = 0;
		while (enumeration.hasMoreElements()) {
			Message m = (Message) enumeration.nextElement();
			received++;
			if (received > messageToSend)
				break;
		}

		browser.close();

		assertEquals(messageToSend, received);
	}

}







                
> java.lang.OutOfMemoryError: Java heap space
> -------------------------------------------
>
>                 Key: AMQ-4487
>                 URL: https://issues.apache.org/jira/browse/AMQ-4487
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: Broker
>    Affects Versions: 5.8.0
>         Environment: OS - Linux 2.6.18-238.el5 #1 SMP Sun Dec 19 14:22:44 EST 2010 x86_64
x86_64 x86_64 GNU/Linux
> Activemq - 5.8
>            Reporter: Subathra Jayaraman
>
> Hi,
> When we browse a queue in webconsole we are getting java.lang.OutOfMemoryError: Java
heap space. 
> Memory allocation -----> -Xms512m -Xmx3G
> When we try to click the queue to view the messages below error is occurring. We recently
moved from 5.7 to 5.8 version. We dint face this issue in 5.7 version.
> Kindly help in fixing the issue.
> java.lang.OutOfMemoryError: Java heap space
>         at java.util.Arrays.copyOf(Arrays.java:2882)
>         at java.io.CharArrayWriter.write(CharArrayWriter.java:88)
>         at java.io.PrintWriter.write(PrintWriter.java:382)
>         at com.opensymphony.module.sitemesh.filter.RoutablePrintWriter.write(RoutablePrintWriter.java:144)
>         at org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:181)
>         at org.apache.jasper.runtime.JspWriterImpl.write(JspWriterImpl.java:449)
>         at org.apache.jasper.runtime.JspWriterImpl.write(JspWriterImpl.java:462)
>         at org.apache.jsp.browse_jsp$browse_jspHelper.invoke0(org.apache.jsp.browse_jsp:382)
>         at org.apache.jsp.browse_jsp$browse_jspHelper.invoke(org.apache.jsp.browse_jsp:450)
>         at org.apache.jsp.tag.web.jms.forEachMessage_tag.doTag(org.apache.jsp.tag.web.jms.forEachMessage_tag:89)
>         at org.apache.jsp.browse_jsp._jspx_meth_jms_forEachMessage_0(org.apache.jsp.browse_jsp:170)
>         at org.apache.jsp.browse_jsp._jspService(org.apache.jsp.browse_jsp:100)
>         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:109)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
>         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:389)
>         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:486)
>         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:380)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
>         at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:652)
>         at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1329)
>         at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:83)
>         at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
>         at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1300)
>         at org.apache.activemq.web.SessionFilter.doFilter(SessionFilter.java:45)
>         at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1300)
>         at org.apache.activemq.web.filter.ApplicationContextFilter.doFilter(ApplicationContextFilter.java:102)
>         at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1300)
>         at com.opensymphony.sitemesh.webapp.SiteMeshFilter.obtainContent(SiteMeshFilter.java:129)
>         at com.opensymphony.sitemesh.webapp.SiteMeshFilter.doFilter(SiteMeshFilter.java:77)
>         at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1300)
>         at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:445)
>         at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
> Thank you.
> Regards,
> Subathra.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message