yeah strange, the length was still 0…
but nonetheless, something else is going on here it seems:
The more spheres I add, the more UniformBuffers stick around. I haven’t checked in the Playground because I’m not sure how to find those in the console with the obfuscation, but it’s probably the same.
My mistake, we do use uniform buffers in the scene, light and mesh objects. We had a leak in the mesh, this PR will fix it:
Regarding the ubo of the default material, it is not released even if you dispose of the material because the scene has a property that points to it: scene._defaultMaterial. You will need to set it to null or undefined if you don’t want to see a ubo leak from it.
Regarding:
window.addEventListener('click', () => {
for (const m of scene.materials) {
m.dispose();
}
sphere.dispose();
sphere2.dispose();
sphere3.dispose();
});
This code won’t release the ubo of the spheres because the event listener exists for the course of the script, and so sphere/sphere2/sphere3 are still reachable by this code and won’t be gargabe collected, meaning their ubo won’t be garbage collected either.
You can do this instead:
const onclick = () => {
for (const m of scene.materials) {
m.dispose();
}
sphere.dispose();
sphere2.dispose();
sphere3.dispose();
window.removeEventListener('click', onclick);
};
window.addEventListener('click', onclick);
I’m quite convinced now that there are no memory leaks present concerning the parts of the Engine that I use. I still have to look into the GPU memory, but that is a bit harder.