0 Replies Latest reply on Aug 10, 2010 7:17 AM by saha_subrata

    Out of Memory Error in java assist 1.0

    saha_subrata

      I am trying to modify the some 1000 class files ,my intension is to insert sys out while entering any method.

      and replacing the class file using to byteCode.

       

      Ex Code snippet:--

       

       

      method.insertBefore(stringToBeInjected);

      cc.writeFile();

      cc.defrost();

       

      byte[] bytes = cc.toBytecode();

       

      FileOutputStream appendedFile = new FileOutputStream(file, false);

      appendedFile.write(bytes);

      appendedFile.close();

      It is doing iteration for all 1000 class files or so files.

       

       

      Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
      at java.util.Arrays.copyOf(Unknown Source)
      at java.io.ByteArrayOutputStream.toByteArray(Unknown Source)
      at com.nds.epg.debug.engine.ClassPool.write(ClassPool.java:431)
      at com.nds.epg.debug.engine.CtClass.toBytecode(CtClass.java:774)
      Any help would be greatly appreciated.