public static void testLargeStrWriteToEx() throws IOException {
        String str = createTestStr();
        ByteArrayOutputStream baos = new ByteArrayOutputStream(str.length()+2);
        for (int i = 0; i < 600; i++) {
            SerializeWriter writer = new SerializeWriter();
            try {
                writer.writeString(str);
                writer.writeToEx(baos, IOUtils.UTF8);
            } finally {
                writer.close();
                baos.reset();
            }
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
            }
        }
    }
Execute toBytes periodically, use tools to analyze JVM memory allocation.
For example, Memory Allocation Record of YourKit java profiler
src/test/java/com/alibaba/fastjson/serializer/SerializeWriterToBytesTest.java