Non-stop instantiation of objects causes oom

Source: Internet
Author: User

Using axis call WebService, the system has been running for a period of time, an OOM has occurred, fortunately, the error message is noted in the log.

Exception in Thread "Thread-1301" Java.lang.OutOfMemoryError:Java heap Spaceat Org.apache.xerces.dom.DeferredDocumentImpl.createChunk (Unknown Source) at Org.apache.xerces.dom.DeferredDocumentImpl.ensureCapacity (Unknown Source) at Org.apache.xerces.dom.DeferredDocumentImpl.createNode (Unknown Source) at Org.apache.xerces.dom.DeferredDocumentImpl.createDeferredDocument (Unknown Source) at Org.apache.xerces.parsers.AbstractDOMParser.startDocument (Unknown Source) at Org.apache.xerces.impl.dtd.XMLDTDValidator.startDocument (Unknown Source) at Org.apache.xerces.impl.XMLDocumentScannerImpl.startEntity (Unknown Source) at Org.apache.xerces.impl.XMLVersionDetector.startDocumentParsing (Unknown Source) at Org.apache.xerces.parsers.XML11Configuration.parse (Unknown Source) at Org.apache.xerces.parsers.XML11Configuration.parse (Unknown Source) at Org.apache.xerces.parsers.XMLParser.parse ( Unknown source) at Org.apache.xerces.parsers.DOMParser.parse (Unknown source) at Org.apache.xerces.jaxp.DocumentBuilderImpl.parse (Unknown Source) at Org.apache.axis.utils.XMLUtils.newDocument (xmlutils.java:369) at Org.apache.axis.utils.XMLUtils.newDocument (xmlutils.java:388) at Org.apache.axis.configuration.FileProvider.configureEngine (fileprovider.java:179) at Org.apache.axis.AxisEngine.init (axisengine.java:172) at org.apache.axis.axisengine.<init> (Axisengine.java : 156) at org.apache.axis.client.axisclient.<init> (axisclient.java:52) at Org.apache.axis.client.Service.getAxisClient (service.java:104) at org.apache.axis.client.service.<init> ( service.java:113) at catic.hotel.server.webservice.pmsservicedata.<init> (pmsservicedata.java:26) at Catic.hotel.server.task.sendcmdtask.<init> (sendcmdtask.java:200) at Catic.hotel.server.task.TaskFactory.getTask (taskfactory.java:155) at Catic.hotel.server.server.ReadData.read ( readdata.java:82) at Catic.hotel.server.server.ReadData.run (readdata.java:57)

Because the system will frequently enter into the sendcmdtask, and I again in this construction method constantly new Pmsservicedata (), and the pmsservice of the non-parametric construction method of the new Service (), The equivalent of causing the service object to be instantiated over time, oom occurs.

Workaround:

Use singleton mode for pmsservicedata, i.e.:

    Private Static NULL ;         // Single Case     Public Static synchronized Pmsservicedata getinstance () {        if(null = = pmsservicedata)            { New Pmsservicedata ();        }         return pmsservicedata;    }

Problem solving.

Non-stop instantiation of objects causes oom

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.