If the RPG procedure calling the Java method is not itself an RPG native method, and the RPG procedure does not take care to free objects it has created, then the job may eventually be unable to create any more objects.
strObject = newString ('abcde');
strObject = trim (strObject);
data = getBytes (strObject);
freeLocalRef (strObject);
beginObjGroup();
strObject = newString ('abcde');
strObject = trim (strObject);
data = getBytes (strObject);
endObjGroup();
strObject = newString ('abcde');
trimmedStrObject = trim (strObject);
data = getBytes (trimmedStrObject);
freeLocalRef (strObject);
freeLocalRef (trimmedStrObject);
bigDec = newBigDecimal (newString ('12.345'));
…
freeLocalRef (bigDec);
tempObj = newString ('12.2345');
bigDec = newBigDecimal (tempObj);
freeLocalRef (tempObj);
…
freeLocalRef (bigDec);