Yes. We are both right.
Since java.lang.String is immutable, the act of changing it’s value creates a new String instance, which one then puts into the pipeline.
There is only ever one occurance of a String value in the JVM. See
[url=“JDK 19 Documentation - Home”]JDK 19 Documentation - Home
The act of Flow Map Copy doesn’t use significant extra RAM. This is not very intuitive, particularly to a old C programmer like me.
[url=“Java SE Specifications”]Java SE Specifications
IData (the pipeline or Documents in the pipeline) holds name/value pairs. You can do the following without a significant RAM hit for the ‘duplicate’ long String values in the pipeline:
String key0 = “Pretend I Am a Very Very Long Value”;
String key1 = new String(“Pretend I Am a Very Very Long Value”);
String key2 = new String(key0);
Object data = {
{ “key0”, key0 },
{ “key1”, key1 },
{ “key2”, key2 },
{ “key3”, “Pretend I Am a Very Very Long Value” },
};
IData pipeline = IDataFactory.create(data);
If I did:
String shorter = key0.substring(1);
I would get an new instance of a String object that takes up key0.length() - 1 characters of RAM.
#Integration-Server-and-ESB#webMethods#Flow-and-Java-services