最近在J2EE项目中,我们将spring-data-mongodb的版本从1.7.1.RELEASE更改为1.10.12.RELEASE,因为安全问题,当调用MongoTemplate.save(Object objectToSave)方法时,java.lang.OutOfMemoryError:在tomcat7启动后大约一天后发生PermGen空间错误,但在spring-data-mongodb的版本发生变化之前从未发生过。 我们尝试增加最大烫发大小,但没有用。我们使用YourKit工具来研究jvm类,然后发现许多类使用'LogRecord_Accessor _'等格式创建。在读取spring-data-commons-1.13.12.RELEASE代码源之后,原因是org.springframework.data.mapping.context。 AbstractMappingContext,相关代码是:
private final PersistentPropertyAccessorFactory persistentPropertyAccessorFactory = new ClassGeneratingPropertyAccessorFactory();
@Document(collection = "AuditLog")
public class LogRecord {
long EVENT_ID;
String TIMESTAMP;
String SUBJECT;
String VERB;
String OBJECT;
String ORG_APP_NAME;
String ORG_APP_IP_ADDRESS;
String CLI_APP_NAME;
String CLI_APP_IP_ADDRESS;
Map<String,String> PREDICATE_MAP;
public Map<String, String> getPREDICATE_MAP() {
return PREDICATE_MAP;
}
public void setPREDICATE_MAP(Map<String, String> pREDICATE_MAP) {
PREDICATE_MAP = pREDICATE_MAP;
}
public long getEVENT_ID() {
return EVENT_ID;
}
public void setEVENT_ID(long eVENT_ID) {
EVENT_ID = eVENT_ID;
}
public String getTIMESTAMP() {
return TIMESTAMP;
}
public void setTIMESTAMP(String tIMESTAMP) {
TIMESTAMP = tIMESTAMP;
}
public String getSUBJECT() {
return SUBJECT;
}
public void setSUBJECT(String sUBJECT) {
SUBJECT = sUBJECT;
}
public String getVERB() {
return VERB;
}
public void setVERB(String vERB) {
VERB = vERB;
}
public String getOBJECT() {
return OBJECT;
}
public void setOBJECT(String oBJECT) {
OBJECT = oBJECT;
}
public String getORG_APP_NAME() {
return ORG_APP_NAME;
}
public void setORG_APP_NAME(String oRG_APP_NAME) {
ORG_APP_NAME = oRG_APP_NAME;
}
public String getORG_APP_IP_ADDRESS() {
return ORG_APP_IP_ADDRESS;
}
public void setORG_APP_IP_ADDRESS(String oRG_APP_IP_ADDRESS) {
ORG_APP_IP_ADDRESS = oRG_APP_IP_ADDRESS;
}
public String getCLI_APP_NAME() {
return CLI_APP_NAME;
}
public void setCLI_APP_NAME(String cLI_APP_NAME) {
CLI_APP_NAME = cLI_APP_NAME;
}
public String getCLI_APP_IP_ADDRESS() {
return CLI_APP_IP_ADDRESS;
}
public void setCLI_APP_IP_ADDRESS(String cLI_APP_IP_ADDRESS) {
CLI_APP_IP_ADDRESS = cLI_APP_IP_ADDRESS;
}
@Override
public String toString() {
return "LogDoc [EVENT_ID=" + EVENT_ID + ", TIMESTAMP=" + TIMESTAMP
+ ", SUBJECT=" + SUBJECT + ", VERB=" + VERB + ", OBJECT="
+ OBJECT + ", ORG_APP_NAME=" + ORG_APP_NAME
+ ", ORG_APP_IP_ADDRESS=" + ORG_APP_IP_ADDRESS
+ ", CLI_APP_NAME=" + CLI_APP_NAME + ", CLI_APP_IP_ADDRESS="
+ CLI_APP_IP_ADDRESS + "]";
}
}
这是spring-data-mongodb的bug,还是我们使用MongoTemplate.save不正确,请帮帮我。感谢