java.lang.OutOfMemoryError: Java heap space with JSON conversion -
listadecretosingolo = new arraylist<>(); listadettagliodecretosingolo = new arraylist<>(); for(int = 0; < 1022; i++){ decretosingolotemp = new decretosingoloviewobject("roma", "abcde3593cxxe", "decreto singolo", date,new bigdecimal(56000), new bigdecimal(343434), new bigdecimal(55656), new bigdecimal(9999)); for(int j = 0; j < 111; j++){ listadettagliodecretosingolo.add(new dettagliodecretosingoloviewobject(22, date, "numero dec pag", "tipo pag", new bigdecimal(45), "nota dec")); } decretosingolotemp.setdetails(listadettagliodecretosingolo); listadecretosingolo.add(decretosingolotemp); } objectwriter ow = new objectmapper().writer().withdefaultprettyprinter(); string jsonlist = null; jsonlist = ow.writevalueasstring(listadecretosingolo);
i want test speed of code above. but, when run it, , tries convert list json string exception:
at com.fasterxml.jackson.core.util.textbuffer.carr(textbuffer.java:703) [jackson-core-2.3.3.jar:2.3.3] @ com.fasterxml.jackson.core.util.textbuffer.expand(textbuffer.java:664) [jackson-core-2.3.3.jar:2.3.3] @ com.fasterxml.jackson.core.util.textbuffer.append(textbuffer.java:455) [jackson-core-2.3.3.jar:2.3.3] @ com.fasterxml.jackson.core.io.segmentedstringwriter.write(segmentedstringwriter.java:67) [jackson-core-2.3.3.jar:2.3.3] @ com.fasterxml.jackson.core.json.writerbasedjsongenerator._flushbuffer(writerbasedjsongenerator.java:1910) [jackson-core-2.3.3.jar:2.3.3] @ com.fasterxml.jackson.core.json.writerbasedjsongenerator.writerawlong(writerbasedjsongenerator.java:496) [jackson-core-2.3.3.jar:2.3.3] @ com.fasterxml.jackson.core.json.writerbasedjsongenerator.writeraw(writerbasedjsongenerator.java:430) [jackson-core-2.3.3.jar:2.3.3] @ com.fasterxml.jackson.core.util.defaultprettyprinter$lf2spacesindenter.writeindentation(defaultprettyprinter.java:472) [jackson-core-2.3.3.jar:2.3.3] @ com.fasterxml.jackson.core.util.defaultprettyprinter.beforeobjectentries(defaultprettyprinter.java:265) [jackson-core-2.3.3.jar:2.3.3] @ com.fasterxml.jackson.core.json.writerbasedjsongenerator._writeppfieldname(writerbasedjsongenerator.java:297) [jackson-core-2.3.3.jar:2.3.3] @ com.fasterxml.jackson.core.json.writerbasedjsongenerator._writefieldname(writerbasedjsongenerator.java:227) [jackson-core-2.3.3.jar:2.3.3] @ com.fasterxml.jackson.core.json.writerbasedjsongenerator.writefieldname(writerbasedjsongenerator.java:116) [jackson-core-2.3.3.jar:2.3.3] @ com.fasterxml.jackson.databind.ser.beanpropertywriter.serializeasfield(beanpropertywriter.java:539) [jackson-databind-2.3.3.jar:2.3.3] @ com.fasterxml.jackson.databind.ser.std.beanserializerbase.serializefields(beanserializerbase.java:644) [jackson-databind-2.3.3.jar:2.3.3] @ com.fasterxml.jackson.databind.ser.beanserializer.serialize(beanserializer.java:152) [jackson-databind-2.3.3.jar:2.3.3] @ com.fasterxml.jackson.databind.ser.impl.indexedlistserializer.serializecontents(indexedlistserializer.java:100) [jackson-databind-2.3.3.jar:2.3.3] @ com.fasterxml.jackson.databind.ser.impl.indexedlistserializer.serializecontents(indexedlistserializer.java:21) [jackson-databind-2.3.3.jar:2.3.3] @ com.fasterxml.jackson.databind.ser.std.asarrayserializerbase.serialize(asarrayserializerbase.java:183) [jackson-databind-2.3.3.jar:2.3.3] @ com.fasterxml.jackson.databind.ser.beanpropertywriter.serializeasfield(beanpropertywriter.java:541) [jackson-databind-2.3.3.jar:2.3.3] @ com.fasterxml.jackson.databind.ser.std.beanserializerbase.serializefields(beanserializerbase.java:644) [jackson-databind-2.3.3.jar:2.3.3] @ com.fasterxml.jackson.databind.ser.beanserializer.serialize(beanserializer.java:152) [jackson-databind-2.3.3.jar:2.3.3] @ com.fasterxml.jackson.databind.ser.impl.indexedlistserializer.serializecontents(indexedlistserializer.java:100) [jackson-databind-2.3.3.jar:2.3.3] @ com.fasterxml.jackson.databind.ser.impl.indexedlistserializer.serializecontents(indexedlistserializer.java:21) [jackson-databind-2.3.3.jar:2.3.3] @ com.fasterxml.jackson.databind.ser.std.asarrayserializerbase.serialize(asarrayserializerbase.java:183) [jackson-databind-2.3.3.jar:2.3.3] @ com.fasterxml.jackson.databind.ser.defaultserializerprovider.serializevalue(defaultserializerprovider.java:114) [jackson-databind-2.3.3.jar:2.3.3] @ com.fasterxml.jackson.databind.objectwriter._configandwritevalue(objectwriter.java:809) [jackson-databind-2.3.3.jar:2.3.3] @ com.fasterxml.jackson.databind.objectwriter.writevalueasstring(objectwriter.java:684) [jackson-databind-2.3.3.jar:2.3.3] @ it.istruzione.hp.scuolesicure.controller.consultapagamenticontroller.ricercaconsultaimpegni(consultapagamenticontroller.java:116) [classes:] @ it.istruzione.hp.scuolesicure.controller.consultapagamenticontroller$$fastclassbyspringcglib$$8a5debc0.invoke(<generated>) [spring-core-4.0.5.release.jar:] @ org.springframework.cglib.proxy.methodproxy.invoke(methodproxy.java:204) [spring-core-4.0.5.release.jar:4.0.5.release] @ org.springframework.aop.framework.cglibaopproxy$cglibmethodinvocation.invokejoinpoint(cglibaopproxy.java:708) [spring-aop-4.0.5.release.jar:4.0.5.release] @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:157) [spring-aop-4.0.5.release.jar:4.0.5.release]
i don't error when list has small size (like 10, 20, 30..). but, when increase size, near thousands or little less, have problem...
there way fix it?
you creating lot of objects, need lot of memory. try using -xmx option increase maximum heap size.
Comments
Post a Comment