Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【Metal】MTLBuffer was not properly released #179

Open
vinsentli opened this issue Sep 20, 2024 · 2 comments
Open

【Metal】MTLBuffer was not properly released #179

vinsentli opened this issue Sep 20, 2024 · 2 comments
Assignees

Comments

@vinsentli
Copy link
Contributor

vinsentli commented Sep 20, 2024

I noticed that even though igl::meta::Buffer is released after running the program for a while, MTLBuffer is not properly released, and the memory keeps increasing. For example, in the screenshot below, there are only 298 objects in igl::metal::Buffer, but CaptureMTLBuffer still has 3882 objects.

One solution I found is to call [MTLBuffer setPurgeableState:MTLPurgeableStateEmpty], which prevents the continuous memory growth even though the number of CaptureMTLBuffer objects doesn't decrease.

My solution:

Buffer::~Buffer(){
  for (auto & buf : mtlBuffers_){
    [buf setPurgeableState:MTLPurgeableStateEmpty];
    buf = nil;
  }
  mtlBuffers_.clear();
}

However, [MTLBuffer setPurgeableState:MTLPurgeableStateEmpty] is typically used in non-ARC environments and theoretically should not be necessary in an ARC environment.

image
@tgoulart
Copy link
Contributor

Capture* objects are associated with frame capture, which we do not control. Does it still happen if you disable "GPU Frame Capture" under the Scheme options?

@vinsentli
Copy link
Contributor Author

@tgoulart Disable "GPU Frame Capture" , it still happen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants