简体   繁体   中英

Strange Out of Memory Exception

We are seeing a very weird situation with our web app. It uses Tomcat 6 and the web service is implemented with Jersey. The service calls below are meant to return JSON data.

The following throws OOM exception:

http://mywebservices/get/some/data/for/1
http://mywebservices/get/some/more/data/for/12345
http://mywebservices/get/some/other/data/for/abc

But, the following works fine:

http://mywebservices/get/some/data/for/12345
http://mywebservices/get/some/more/data/for/1

These are just made up calls to show what is happening. We have real time monitoring services that show ~5 GB available memory for JVM. We believe the OOM the Tomcat is throwing at us is a fake/incorrect response. The funny thing is even for completely different web services, the stack trace shown on the browser remains the same. We are very sure we are seeing the trace that is totally irrelevant given the web service request. So we are figuring out if we actually have a leak.

Meantime, it would be great to know if anybody has encountered this before.

Thanks.

Ok, so we believe we have found the root cause for this issue. There was a leak indeed because of the usage of ObjectOutputStream and ObjectInputStream.

Now ObjectOutputStream has a reset() method that can clear the references but there is nothing like that for the ObjectInputStream.

This link helped us: Java out of heap space during serialization

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM