But there is still some work to do. Especially with all meshes that were detached from the scene graph and aren’t needed anymore. If a mesh was detached, the buffers allocated via BufferUtils (and therefore jemalloc at the end) are not destroyed. This causes a memory leak and I bet there are still some other places where buffer needs to be destroyed correctly.
Actually they should at least be destroyed once the GC feels like it, but yeah if we had a faste explicit system that can fast kill them in a generic way, that would be pretty nice
finalize is worse (it has a lot of ugly implications, and requires 2 gc roundtrips), if necessary a phantomqueue (look at the tracking in bufferutils) is a way better way. Actually that could be replicated similar for that allocator. That however does not solve the problem of the gc only running rarely, but it should not overflow anymore.
I’m just saying… it seems like there are already hooks in place for this.
At any rate, if this special allocator creates buffers that Java can’t free normally then ALL of the changes should be in the special allocator. They do not belong in BufferUtils directly as they only apply to the special allocator… the one with the issue.