I want to avoid crash of 3d tiles in the Browser based on the comparison between the largest memory I can allocate in the browser and the totalMemoryUsageInBytes of the Cesium3DTileset.
It seems windows.perfromance.memory is not meaningful to tell me the limitation of memory I can use.
-
When my GPU and CPU memory is large enough, the ‘windows.perfromance.memory.jsHeapSizeLimit’ is always 4GB around. However, I can allocate almost 8GB memory actually
-
There is a limitation of the size we can allocate each time, I guess it is <2GB
My question is: do you have any suggestions to figure out the largest memory I can allocate practically.
Thank you for your sharing.
.
My test example is based on the ‘VertexArraySpec’:
var nUnitGB = 1.9;
var size = nUnitGB * 0.25*1024*1024*1024; // 1GB of Float32Array
var count = 8*10; // try to get the limitation of memory we can allocate
var buf=[];
var positionBuffer = [];
var attributes=[];
var va = [];
for(var j=0;j<count;j++)
{
buf[j]= new Float32Array(size);
for(var i=0;i<size;i++){
buf[j][i] = 1.0;
}
positionBuffer[j] = Buffer.createVertexBuffer({
context: context,
typedArray : buf[j],
usage: BufferUsage.STATIC_DRAW,
});
attributes[j] = [
{
index: 0,
enabled: true,
vertexBuffer: positionBuffer[j],
componentsPerAttribute: 3,
componentDatatype: ComponentDatatype.FLOAT,
normalize: false,
offsetInBytes: 0,
strideInBytes: 0,
instanceDivisor: 0,
// tightly packed
},
];
va[j] = new VertexArray({
context: context,
attributes: attributes[j],
});
va[j]._bind();
console.log(j+1);
}
for(var j=0;j<count;j++)
{
va[j]._unBind();
va[j].destroy();
}