Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

java.lang.OutOfMemoryError: Java heap space with nifi

java.lang.OutOfMemoryError: Java heap space with nifi

New Contributor

I am using execute script processor of nifi, i have created a ECMA Script and some times it works and some time it throws java.lang.OutOfMemoryError: Java heap space

2 REPLIES 2
Highlighted

Re: java.lang.OutOfMemoryError: Java heap space with nifi

hello

Without knowing what script you are executing exactly hard to see if it comes from your script or from the nifi configs.

The bootstrap.conf file in the conf directory allows users to configure settings for how NiFi should be started. This includes parameters, such as the size of the Java Heap, what Java command to run, and Java System Properties. What is your current configuration.

This config guide might help as well:

https://nifi.apache.org/docs/nifi-docs/html/administration-guide.html#configuration-best-practices

Re: java.lang.OutOfMemoryError: Java heap space with nifi

New Contributor

hi i am using this script

var flowFile = session.get(); try{ if (flowFile != null) { var StreamCallback = Java.type("org.apache.nifi.processor.io.StreamCallback") var IOUtils = Java.type("org.apache.commons.io.IOUtils") var StandardCharsets = Java.type("java.nio.charset.StandardCharsets") var newObj = { "results": {} }; flowFile = session.write(flowFile, new StreamCallback(function(inputStream, outputStream) { var text = IOUtils.toString(inputStream, StandardCharsets.UTF_8) var obj = JSON.parse(text) var invalid = false; var reason = []; if (obj != undefined && obj.json != undefined && obj.json.meters != undefined && obj.json.meters.length > 0) { obj.json.meters.forEach(function(meter, i) { if (meter.dailydata != undefined && meter.dailydata.length > 0) { } else { invalid = true; reason.push("dailydata undefined " + JSON.stringify(meter, null, '\t')); } //console.log("sum is "+newObj.json.meters[i].intervalSum); }); } else { invalid = true; reason.push("meters are undefined " + JSON.stringify(obj, null, '\t')) } if (invalid) { newObj.results.action = "INVALID"; newObj.results.faultymeters = reason; } else { newObj.results.action = "COMPLETE"; } /*for(var key in obj.rating){ var attrName = key; var attrValue = obj.rating[key]; if(attrName != "primary") { newObj.SecondaryRatings[attrName] = {"id": attrName, "Range": 5, "Value": attrValue.value}; } }*/ outputStream.write(JSON.stringify(obj).getBytes(StandardCharsets.UTF_8)) })) //flowFile = session.putAttribute(flowFile, "filename", flowFile.getAttribute('filename').split('.')[0] + '_translated.json') flowFile = session.putAttribute(flowFile, "validation_data", JSON.stringify(newObj)) if (newObj.results.action == "INVALID") { session.transfer(flowFile, REL_FAILURE) } else { session.transfer(flowFile, REL_SUCCESS) } } else { flowFile = session.putAttribute(flowFile, "validation_data", "NULL data") session.transfer(flowFile, REL_FAILURE) } }catch(e){ flowFile = session.putAttribute(flowFile, "validation_data", e) session.transfer(flowFile, REL_FAILURE) }

basically it validates the json for me

i m using 2gb of memory set in bootstrap.conf file and my each flow file is not more than 100 MB