You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by tonywestonuk <to...@totspics.com> on 2015/11/02 10:12:09 UTC

Websocket Session memory leak

Hi,   I think there is a websocket memory leak bug.   I am using the latest
version of TomEE (1.7.2).


It is easy to reproduce.  See Below, then open the index.html page in a
browser, refresh say 50 times.  

Look at the heapdump in VisualVM (after hitting the GC button a dozen
times).  Yo will find that 50 instances of MyWebsocket have been created. 
And also 50 instances of org.apache.tomcat.websocket.wsSession have been
created.  

These instances are retained because of references to them from:
org.apache.openejb.core.WebContext - creationalContext

I don't think they will ever be removed. 


STEPS TO REPRODUCE:

Create a new Websocket handler class:

@ServerEndpoint(value = "/ws")
public class MyWebsocket {

	@OnOpen
	public void wsOpen(Session session){
		System.out.println("WS Opened");
	}
	
	@OnClose
	public void wsClosed(Session session){
		System.out.println("WS Closed");
	}
}


...and index.html with javascript to open the websocket:

<html>

</html>




--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Websocket-Session-memory-leak-tp4676663.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Websocket Session memory leak

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Tomcat fixed the server usage so we should have a proper fix for tomee 7.
in 1 week - time tomca is released.


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com>

2015-12-03 12:08 GMT+01:00 tonywestonuk <to...@totspics.com>:

> Ok, not sure if this fix will make it to 1.7.3...., I notice you guys are
> having a vote if 1.7.3 is going ahead...
>
> But, anyhow, I've now moved my websocket endpoint code into a separate
> project that is hosted on Tomcat, which talks to tomee over multicast
> sockets.  I didn't realise that websockets can break the same origin
> rule!....but as they can, I am able to do this easy.
>
> I think its a more scalable solution now anyhow, I can just add more tomcat
> servers if I get too many people opening up too many persistent
> connections.
> And, while developing, that same project works in TomEE as im restarting
> the
> server every 5 mins anyhow so the bug does not cause me a problem.
>
> :-D
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/Websocket-Session-memory-leak-tp4676663p4677108.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>

Re: Websocket Session memory leak

Posted by tonywestonuk <to...@totspics.com>.
Ok, not sure if this fix will make it to 1.7.3...., I notice you guys are
having a vote if 1.7.3 is going ahead...

But, anyhow, I've now moved my websocket endpoint code into a separate
project that is hosted on Tomcat, which talks to tomee over multicast
sockets.  I didn't realise that websockets can break the same origin
rule!....but as they can, I am able to do this easy. 

I think its a more scalable solution now anyhow, I can just add more tomcat
servers if I get too many people opening up too many persistent connections. 
And, while developing, that same project works in TomEE as im restarting the
server every 5 mins anyhow so the bug does not cause me a problem.

:-D



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Websocket-Session-memory-leak-tp4676663p4677108.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Websocket Session memory leak

Posted by Romain Manni-Bucau <rm...@gmail.com>.
All apps using tomcat InstanceManager for other instances than web
components - the servlet know components filter, servlet, listeners...

Websocket does.
Le 16 nov. 2015 04:51, "Felipe Jaekel" <fk...@gmail.com> a écrit :

> Hi,
>
> May this affect Atmosphere based webapps?
>
> Thanks
>
>
>
> 2015-11-02 12:32 GMT-02:00 Romain Manni-Bucau <rm...@gmail.com>:
>
> > Very good catch. Will get fixed this week on 7.x first but backport to
> 1.7
> > is easy then for this case.
> > Ok,  Bug created:
> >
> > https://issues.apache.org/jira/browse/TOMEE-1649
> >
> >
> > Thanks.
> >
> >
> >
> > --
> > View this message in context:
> >
> >
> http://tomee-openejb.979440.n4.nabble.com/Websocket-Session-memory-leak-tp4676663p4676668.html
> > Sent from the TomEE Users mailing list archive at Nabble.com.
> >
>

Re: Websocket Session memory leak

Posted by Felipe Jaekel <fk...@gmail.com>.
Hi,

May this affect Atmosphere based webapps?

Thanks



2015-11-02 12:32 GMT-02:00 Romain Manni-Bucau <rm...@gmail.com>:

> Very good catch. Will get fixed this week on 7.x first but backport to 1.7
> is easy then for this case.
> Ok,  Bug created:
>
> https://issues.apache.org/jira/browse/TOMEE-1649
>
>
> Thanks.
>
>
>
> --
> View this message in context:
>
> http://tomee-openejb.979440.n4.nabble.com/Websocket-Session-memory-leak-tp4676663p4676668.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>

Re: Websocket Session memory leak

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Very good catch. Will get fixed this week on 7.x first but backport to 1.7
is easy then for this case.
Ok,  Bug created:

https://issues.apache.org/jira/browse/TOMEE-1649


Thanks.



--
View this message in context:
http://tomee-openejb.979440.n4.nabble.com/Websocket-Session-memory-leak-tp4676663p4676668.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Websocket Session memory leak

Posted by tonywestonuk <to...@totspics.com>.
Ok,  Bug created:

https://issues.apache.org/jira/browse/TOMEE-1649


Thanks.



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Websocket-Session-memory-leak-tp4676663p4676668.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Websocket Session memory leak

Posted by Jonathan Gallimore <jo...@gmail.com>.
Hi,

Can you log an issue here for us: https://issues.apache.org/jira

Many thanks

Jon

On Mon, Nov 2, 2015 at 12:53 PM, tonywestonuk <to...@totspics.com> wrote:

> Ok, I tried this using the latest snapshot:
> apache-tomee-1.7.3-20150617.041057-45-jaxrs  , and the memory leak is
> there.
>
> For info, I also tried with vanilla Tomcat (7.0.63), and can confirm this
> bug does not exist there!.  It is a problem specific to TomEE.
>
> Shall I raise a bug report, or is there something more I should be doing
> with TomEE to prevent this happening?  As it stands, I would classify it as
> a blocker, as I cant use Websockets at all as my server hangs with
> out-of-memory errors after so many requests.
>
> Thanks,
> Tony.
>
>
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/Websocket-Session-memory-leak-tp4676663p4676666.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>

Re: Websocket Session memory leak

Posted by tonywestonuk <to...@totspics.com>.
Ok, I tried this using the latest snapshot:
apache-tomee-1.7.3-20150617.041057-45-jaxrs  , and the memory leak is there.

For info, I also tried with vanilla Tomcat (7.0.63), and can confirm this
bug does not exist there!.  It is a problem specific to TomEE.    

Shall I raise a bug report, or is there something more I should be doing
with TomEE to prevent this happening?  As it stands, I would classify it as
a blocker, as I cant use Websockets at all as my server hangs with
out-of-memory errors after so many requests.  

Thanks,
Tony.





--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Websocket-Session-memory-leak-tp4676663p4676666.html
Sent from the TomEE Users mailing list archive at Nabble.com.