Buffer, array as well as typed arrays like Uint8array all have (231-1)=2,147,483,647 as maximal number of elements.
All allocations need linear runtime, because of initialization of the data requested.
GatewayScript does not provide Buffer.allocUnsafe() from nodejs, but even that requires linear runtime, see
So what is the biggest size of memory you can request in GatewayScript, and what time does it take?
Because of index restriction mentioned above, Uint32array seems to be the biggest you can get.
Here you see that it takes 0.75s/2.9s to allocate 2GB/8GB of Uint8/Uint32 array (your mileage may vary depending on your DataPower model, IDG gives you 160GB memory out of 192GB, virtual appliances provide what you configured):
💻 coproc2 2d.js <('') http://dp3-l3:2227; echo
745 2886 / (42) 0
💻 cat 2d.js
var servicevars = require ('service-metadata');
var N=2000000000, t0, t1, t2, t3;
var A=new Uint8Array(N);
var B=new Uint32Array(N);
session.output.write ((t1-t0)+" "+(t2-t1)+" / ("+A[N-1]+") "+(t3-t2));