I noticed a memory leak when calling setMultiDraw several times in a row.
Allocate is always called, which results in the creation of a StorageBuffer while the previous buffer is not deleted.
|
this.storage = new StorageBuffer(this.device, this.gpuIndirect.byteLength, BUFFERUSAGE_INDIRECT | BUFFERUSAGE_COPY_DST); |
It would also be good if old data was saved and not reset then allocate.
/**
* Allocate AoS buffer and backing storage buffer.
* @param {number} maxCount - Number of sub-draws.
*/
allocate(maxCount) {
this.storage?.destroy(); // <--- DISPOSE EXISTS
this.gpuIndirect = new Uint32Array(5 * maxCount);
this.gpuIndirectSigned = new Int32Array(this.gpuIndirect.buffer);
this.storage = new StorageBuffer(this.device, this.gpuIndirect.byteLength, BUFFERUSAGE_INDIRECT | BUFFERUSAGE_COPY_DST);
}
I noticed a memory leak when calling setMultiDraw several times in a row.
Allocate is always called, which results in the creation of a StorageBuffer while the previous buffer is not deleted.
engine/src/scene/mesh-instance.js
Line 1224 in d09fd9f
engine/src/platform/graphics/webgpu/webgpu-draw-commands.js
Line 42 in d09fd9f
It would also be good if old data was saved and not reset then allocate.