Ah39 opened a new issue #499: fastjson parse String may cause the memory leak . URL: https://github.com/apache/rocketmq/issues/499 **In JDK Version 1.6.45 ,fastjson parese String, in JDK 1.6.45, String class have the filed ( private final char value[] ) , the value hold the origin jsonStr . So If the string is hold by a object, so the origin jsonStr canot gc , may cause the memory leak. In namesrv RouteInfoManager have the topicName reference , hold the total RegisterBrokerBody jsonStr** `public class TestFastJson { @Test public void testStringJson() throws IllegalAccessException, NoSuchFieldException{ StringList stringList = new StringList(); List<String> list = new ArrayList<String>(); for(int i=0;i<3;i++){ list.add("hello_str"+i); } stringList.setStringList(list); String jsonStr = JSON.toJSONString(stringList); System.out.println(jsonStr); StringList personList2 = JSON.parseObject(jsonStr, StringList.class); List<String> list2 = personList2.getStringList(); for(String str : list2){ char[] data = (char[]) getValue(str, "value"); String strFromChar = String.valueOf(data); System.out.println("str="+str+" from_char_str "+strFromChar); assert(strFromChar.equals(jsonStr)); } } public static Object getValue(Object instance, String fieldName) throws IllegalAccessException, NoSuchFieldException { Field field = instance.getClass().getDeclaredField(fieldName); field.setAccessible(true); // set true return field.get(instance); } public static class StringList { private List<String> stringList; public List<String> getStringList() { return stringList; } public void setStringList(List<String> stringList) { this.stringList = stringList; } } }`
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
