hiyoucai created THRIFT-2284: -------------------------------- Summary: java.lang.OutOfMemoryError: Java heap space Key: THRIFT-2284 URL: https://issues.apache.org/jira/browse/THRIFT-2284 Project: Thrift Issue Type: Bug Components: Java - Library Affects Versions: 0.7 Environment: Thrift Server start up by Resin Server at Linux system. Reporter: hiyoucai Priority: Critical Fix For: 0.9.1
【1】The first version application Environment: # cat /proc/version Linux version 3.5.0-23-generic (buildd@komainu) (gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) ) #35~precise1-Ubuntu SMP Fri Jan 25 17:13:26 UTC 2013 # java -version java version "1.6.0_45" Java(TM) SE Runtime Environment (build 1.6.0_45-b06) Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode) #thrift version is 0.7 Java Server code like following: public void start() { try { logger.info("TNonblockingServer start ...."); TProcessor tprocessor = new IconOpenService.Processor<IconOpenService.Iface>(iconOpenServiceImpl); TNonblockingServerSocket tnbSocketTransport = new TNonblockingServerSocket(19875); TNonblockingServer.Args tnbArgs = new TNonblockingServer.Args(tnbSocketTransport); tnbArgs.processor(tprocessor); tnbArgs.transportFactory(new TFramedTransport.Factory()); tnbArgs.protocolFactory(new TBinaryProtocol.Factory()); TServer server = new TNonblockingServer(tnbArgs); logger.info("TNonblockingServer start OK1...."); server.serve(); logger.info("TNonblockingServer start OK2...."); } catch (Exception e) { logger.info("TNonblockingServer start ERROR!!!"); e.printStackTrace(); } } Problem description: the thrift server interface invoked per day is much higher.as following: # wc -l thrift.log.20131209 55598276 thrift.log In general, the thrift server will be creshed down about 16pm. I much restart thrift server again an d again, it is very terrible,My boss will kill me(oh.oh). I have monitor the JVM,Some information as following: linux top command result is that the RES item is 9.2G Why use so many memory?so crazy. So I use Jmap command print the jvm info that as following: Object Histogram: num #instances #bytes Class description -------------------------------------------------------------------------- 1: 2493990 191419432 char[] 2: 1371792 43897344 java.lang.String 3: 525011 42306448 int[] 4: 356604 17116992 java.nio.HeapByteBuffer 5: 299290 14365920 java.nio.HeapCharBuffer 6: 70742 10203032 * ConstMethodKlass 7: 70742 9629584 * MethodKlass 8: 342788 8226912 java.lang.StringBuffer 9: 341661 8199864 java.lang.StringBuilder 10: 6644 7149072 * ConstantPoolKlass 11: 133484 6407232 org.springframework.aop.framework.ReflectiveMethodInvocation 12: 101052 6096736 * SymbolKlass 13: 144401 5776040 java.util.HashMap$KeyIterator 14: 6644 5039192 * InstanceKlassKlass 15: 160734 4881928 java.lang.Object[] 16: 149160 4773120 java.util.AbstractList$Itr 17: 59294 4269168 org.apache.log4j.spi.LoggingEvent 18: 5359 4171640 * ConstantPoolCacheKlass 19: 164812 3955488 java.util.LinkedList$Entry 20: 109117 3491744 java.util.HashMap$Entry 21: 59069 3307864 org.apache.thrift.protocol.TBinaryProtocol Just a moment, Java code throw an exception as following: 2013-12-09 16:01:32,181 ERROR [,Thread-44] - [org.apache.thrift.server.TNonblockingServer] - run() exiting due to uncaught error java.lang.OutOfMemoryError: Java heap space at java.nio.HeapByteBuffer.<init>(HeapByteBuffer.java:39) at java.nio.ByteBuffer.allocate(ByteBuffer.java:312) at org.apache.thrift.server.TNonblockingServer$FrameBuffer.read(TNonblockingServer.java:491) at org.apache.thrift.server.TNonblockingServer$SelectThread.handleRead(TNonblockingServer.java:359) at org.apache.thrift.server.TNonblockingServer$SelectThread.select(TNonblockingServer.java:304) at org.apache.thrift.server.TNonblockingServer$SelectThread.run(TNonblockingServer.java:243) 【2】The seconde version application Environment: because The first version application throw an java.lang.OutOfMemoryError: Java heap space that i don't know how to do. -- This message was sent by Atlassian JIRA (v6.1.4#6159)