stride3d / stride3d/stride

Buffers of Models created by PrimitiveProceduralModelBase are not automatically collected

Open
#2,101 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

area-Doc bug enhancement
Dominant language
C#
Stars
7.8k
Forks
1.2k
Avg merge
2d 17h
Merged PRs (30d)
49

Description

Release Type: GitHub

Version: 4.2.0.2043

Platform(s): Windows 11

Describe the bug
Memory used by Vertex and Index buffers in procedural meshing using an implementation of PrimitiveProceduralModelBase are not automatically dealt with/disposed by the garbage collector or entity system when an entity containing a model component with a procedural model falls out of scope.

To Reproduce
Steps to reproduce the behavior:

  1. Implement PrimitiveProceduralModelBase.
  2. Generate the Model and add the model to a model component
  3. Add the model component to the entity and add the entity to a scene
  4. Remove the entity from the scene and remove all references to it
  5. Vertex and Index buffers appear to remain in memory no matter how long the application runs.

Expected behavior
When an entity and its components fall out of scope, the whole memory usage of the entity and its components should be collected at some point.

Screenshots
N/A

Log and callstacks
N/A

Additional context
As far as I understand it from talking to @Eideren , runtime created meshes are expected to be handled by the user, but this is not explicitly clear anywhere I read. I don't know the best way to solve this but one idea I have is to explicitly state somewhere (preferably on PrimitiveProceduralModelBase itself) that models created using implementations of this class, and other procedural meshing classes that I don't know about, are expected to be manually cleaned up.

Additional Note
Calling an explicit GC.Collect() does not seem to dispose of the buffers correctly either despite no references to it existing. (Could a finalizer be added?)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with an implementation of PrimitiveProceduralModelBase, a generated model, and an entity removed from the scene. Trace the lifetime of the model component's vertex and index buffers after references are removed, then determine whether the expected result is automatic cleanup or clarified manual disposal guidance. Done means the buffer ownership and cleanup behavior are verified.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
game-dev, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.