0

I'm developing a NIFI custom processor using scala with has the feature of creating a long string:

var testString: String = "test"

val Mapped: List[Map[String, String]] = filtered.map(each=>{
        each.map(element=>{
          // other logics
          test = "|" + element._1 + "=" +  element._2 + "|" + test // concat string (this line throws error)
          (1->test)
        
       }).toMap
   }
 )

The code throws an exception:

failed to process session due to java.lang.OutOfMemoryError: Java heap space; Processor Administratively Yielded for 1 sec: java.lang.OutOfMemoryError: Java heap space
java.lang.OutOfMemoryError: Java heap space

I have tried with string builder, list to string kind of ways and it throws the same error, and finally, I tried to limit the string length without increasing the heap size (maximum length of string, break string to array) to continue the program with a maximum length that can handle.

But from time to time it shows the different lengths of the string when exceptions occurred.

How can I solve this problem?

mkrieger1
  • 14,486
  • 4
  • 43
  • 54
Dulanga Heshan
  • 1,222
  • 17
  • 28

0 Answers0