306 Star 866 Fork 262

闲.大赋 / beetl2.0

关于 ObjectUtil 深度复制一个对象(copy)接口问题 [Top]

Backlog
草者  Opened this issue

项目中使用了该模板引擎在压测过程中出现问题,该方法存在资源没有释放问题,建议能优化一下。JVM异常如下:
Register to memory mapping:

RAX=
[error occurred during error reporting (printing register info), id 0xb]

Stack: [0x00007faf12ec0000,0x00007faf12f01000], sp=0x00007faf12efa8c0, free space=234k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V [libjvm.so+0x91dc71] SymbolTable::lookup(Symbol const*, int, int, Thread*)+0xe1
V [libjvm.so+0x8d18f7] SignatureStream::as_symbol(Thread*)+0x37
V [libjvm.so+0x7d5781] methodOopDesc::load_signature_classes(methodHandle, Thread*)+0x1b1
V [libjvm.so+0x44f121] CompileBroker::compile_method(methodHandle, int, int, methodHandle, int, char const*, Thread*)+0x1c1
V [libjvm.so+0x43c00f] SimpleCompPolicy::method_invocation_event(methodHandle, JavaThread*)+0xef
V [libjvm.so+0x43b492] NonTieredCompPolicy::event(methodHandle, methodHandle, int, int, CompLevel, nmethod*, JavaThread*)+0x102
V [libjvm.so+0x5f8847] InterpreterRuntime::frequency_counter_overflow_inner(JavaThread*, unsigned char*)+0x157
V [libjvm.so+0x5fc7d6] InterpreterRuntime::frequency_counter_overflow(JavaThread*, unsigned char*)+0x16
j java.io.ObjectStreamClass$FieldReflector.getPrimFieldValues(Ljava/lang/Object;[B)V+0
J 4351 C2 java.io.ObjectOutputStream.defaultWriteFields(Ljava/lang/Object;Ljava/io/ObjectStreamClass;)V (270 bytes) @ 0x00007faf45984d64 [0x00007faf45984c80+0xe4]
j java.io.ObjectOutputStream.writeSerialData(Ljava/lang/Object;Ljava/io/ObjectStreamClass;)V+211
j java.io.ObjectOutputStream.writeOrdinaryObject(Ljava/lang/Object;Ljava/io/ObjectStreamClass;Z)V+137
j java.io.ObjectOutputStream.writeObject0(Ljava/lang/Object;Z)V+506
J 4351 C2 java.io.ObjectOutputStream.defaultWriteFields(Ljava/lang/Object;Ljava/io/ObjectStreamClass;)V (270 bytes) @ 0x00007faf4598511c [0x00007faf45984c80+0x49c]
j java.io.ObjectOutputStream.writeSerialData(Ljava/lang/Object;Ljava/io/ObjectStreamClass;)V+211
j java.io.ObjectOutputStream.writeOrdinaryObject(Ljava/lang/Object;Ljava/io/ObjectStreamClass;Z)V+137
j java.io.ObjectOutputStream.writeObject0(Ljava/lang/Object;Z)V+506
J 4351 C2 java.io.ObjectOutputStream.defaultWriteFields(Ljava/lang/Object;Ljava/io/ObjectStreamClass;)V (270 bytes) @ 0x00007faf4598511c [0x00007faf45984c80+0x49c]
j java.io.ObjectOutputStream.writeSerialData(Ljava/lang/Object;Ljava/io/ObjectStreamClass;)V+211
j java.io.ObjectOutputStream.writeOrdinaryObject(Ljava/lang/Object;Ljava/io/ObjectStreamClass;Z)V+137
j java.io.ObjectOutputStream.writeObject0(Ljava/lang/Object;Z)V+506
j java.io.ObjectOutputStream.writeArray(Ljava/lang/Object;Ljava/io/ObjectStreamClass;Z)V+533
j java.io.ObjectOutputStream.writeObject0(Ljava/lang/Object;Z)V+467
J 4351 C2 java.io.ObjectOutputStream.defaultWriteFields(Ljava/lang/Object;Ljava/io/ObjectStreamClass;)V (270 bytes) @ 0x00007faf4598511c [0x00007faf45984c80+0x49c]
j java.io.ObjectOutputStream.writeSerialData(Ljava/lang/Object;Ljava/io/ObjectStreamClass;)V+211
j java.io.ObjectOutputStream.writeOrdinaryObject(Ljava/lang/Object;Ljava/io/ObjectStreamClass;Z)V+137
j java.io.ObjectOutputStream.writeObject0(Ljava/lang/Object;Z)V+506
J 4351 C2 java.io.ObjectOutputStream.defaultWriteFields(Ljava/lang/Object;Ljava/io/ObjectStreamClass;)V (270 bytes) @ 0x00007faf4598511c [0x00007faf45984c80+0x49c]
j java.io.ObjectOutputStream.writeSerialData(Ljava/lang/Object;Ljava/io/ObjectStreamClass;)V+211
j java.io.ObjectOutputStream.writeOrdinaryObject(Ljava/lang/Object;Ljava/io/ObjectStreamClass;Z)V+137
j java.io.ObjectOutputStream.writeObject0(Ljava/lang/Object;Z)V+506
j java.io.ObjectOutputStream.writeArray(Ljava/lang/Object;Ljava/io/ObjectStreamClass;Z)V+533
j java.io.ObjectOutputStream.writeObject0(Ljava/lang/Object;Z)V+467
J 4351 C2 java.io.ObjectOutputStream.defaultWriteFields(Ljava/lang/Object;Ljava/io/ObjectStreamClass;)V (270 bytes) @ 0x00007faf4598511c [0x00007faf45984c80+0x49c]
j java.io.ObjectOutputStream.writeSerialData(Ljava/lang/Object;Ljava/io/ObjectStreamClass;)V+211
j java.io.ObjectOutputStream.writeOrdinaryObject(Ljava/lang/Object;Ljava/io/ObjectStreamClass;Z)V+137
j java.io.ObjectOutputStream.writeObject0(Ljava/lang/Object;Z)V+506
J 4351 C2 java.io.ObjectOutputStream.defaultWriteFields(Ljava/lang/Object;Ljava/io/ObjectStreamClass;)V (270 bytes) @ 0x00007faf4598511c [0x00007faf45984c80+0x49c]
j java.io.ObjectOutputStream.writeSerialData(Ljava/lang/Object;Ljava/io/ObjectStreamClass;)V+211
j java.io.ObjectOutputStream.writeOrdinaryObject(Ljava/lang/Object;Ljava/io/ObjectStreamClass;Z)V+137
j java.io.ObjectOutputStream.writeObject0(Ljava/lang/Object;Z)V+506
j java.io.ObjectOutputStream.writeArray(Ljava/lang/Object;Ljava/io/ObjectStreamClass;Z)V+533
j java.io.ObjectOutputStream.writeObject0(Ljava/lang/Object;Z)V+467
J 4351 C2 java.io.ObjectOutputStream.defaultWriteFields(Ljava/lang/Object;Ljava/io/ObjectStreamClass;)V (270 bytes) @ 0x00007faf4598511c [0x00007faf45984c80+0x49c]
j java.io.ObjectOutputStream.writeSerialData(Ljava/lang/Object;Ljava/io/ObjectStreamClass;)V+211
j java.io.ObjectOutputStream.writeOrdinaryObject(Ljava/lang/Object;Ljava/io/ObjectStreamClass;Z)V+137
j java.io.ObjectOutputStream.writeObject0(Ljava/lang/Object;Z)V+506
J 4483 C2 java.io.ObjectOutputStream.writeObject(Ljava/lang/Object;)V (38 bytes) @ 0x00007faf459bbe24 [0x00007faf459bbde0+0x44]
j org.beetl.core.om.ObjectUtil.copy(Ljava/lang/Object;)Ljava/lang/Object;+29
j org.beetl.core.statement.ProgramMetaData.copy()Lorg/beetl/core/statement/ProgramMetaData;+1
j org.beetl.core.engine.FastRuntimeEngine.createProgram(Lorg/beetl/core/Resource;Ljava/io/Reader;Ljava/util/Map;Ljava/lang/String;Lorg/beetl/core/GroupTemplate;)Lorg/beetl/core/statement/Program;+18
j org.beetl.core.GroupTemplate.loadTemplate(Lorg/beetl/core/Resource;Z)Lorg/beetl/core/statement/Program;+195
j org.beetl.core.GroupTemplate.getTemplateByLoader(Ljava/lang/String;Lorg/beetl/core/ResourceLoader;Z)Lorg/beetl/core/Template;+48
j org.beetl.core.GroupTemplate.getTemplate(Ljava/lang/String;)Lorg/beetl/core/Template;+7

29 xiandafu 1578913709 total 2 participants

Comments (3)

29 xiandafu 1578913709
闲.大赋 2017-05-04 21:53 owner

最后的异常显示什么 outofmemeory,还是 虚拟机宕机?

29 xiandafu 1578913709
闲.大赋 2017-05-04 22:02 owner

具体压测的环境是什么,模拟多少个模板?并发是怎么样的?

JVM配置和版本是什么

草者 2017-06-03 22:14

不是outofmemeory异常,时直接JVM宕机了。
有一个页面采用beet作为模板,压测打开该页面,后面我把ObjectUtil作了下修改,已经OK:
public static Object copy(Object o) {

if (o instanceof java.io.Serializable) {
  ByteArrayOutputStream bs = null;
  ObjectOutputStream dos = null;
  ByteArrayInputStream is = null;
  ObjectInputStream ios = null;
  try {
    bs = new ByteArrayOutputStream(DEFAULT_BUFFER_SIZE);
    dos = new ObjectOutputStream(bs);
    dos.writeObject(o);
    is = new ByteArrayInputStream(bs.toByteArray());
    ios = new ObjectInputStream(is);
    Object copy = ios.readObject();
    return copy;
  } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
  } catch (ClassNotFoundException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
  } finally {
    if (ios != null) {
      try {
        ios.reset();
      } catch (IOException e) {
      }
      IOUtils.closeQuietly(ios);
    }
    if (is != null) {
      is.reset();
      IOUtils.closeQuietly(is);
    }
    if (dos != null) {
      try {
        dos.reset();
      } catch (IOException e) {
      }
      IOUtils.closeQuietly(dos);
    }
    if (bs != null) {
      bs.reset();
      IOUtils.closeQuietly(bs);
    }
  }

}

return null;

}

Sign in to comment

Assignees
Labels
bug
Projects
Milestones
Branches
Planed to start
Not set
Planed to end
Not set
Top level
Priority
Java
1
https://gitee.com/xiandafu/beetl2.0.git
git@gitee.com:xiandafu/beetl2.0.git
xiandafu
beetl2.0
beetl2.0

Search