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

ebiten: add info to know how much memory is allocated for GPU textures #3205

Open
11 tasks
hajimehoshi opened this issue Mar 1, 2025 · 2 comments
Open
11 tasks

Comments

@hajimehoshi
Copy link
Owner

hajimehoshi commented Mar 1, 2025

Operating System

  • Windows
  • macOS
  • Linux
  • FreeBSD
  • OpenBSD
  • Android
  • iOS
  • Nintendo Switch
  • PlayStation 5
  • Xbox
  • Web Browsers

What feature would you like to be added?

Go's GC doesn't recognize allocated memory for GPU. For example, an object handling a GPU texture (*ebiten.Image), and GC recognizes the memory usage of the object as only a struct size. Thus, image objects don't pressure GC, and this tends to cause memory bloat on GPU, even though too many (no-longer-referred) images are created. This is a serious problem especially in some devices that have unified memory for CPU and GPU.

At least, we want a way to know texture memory usages. Let's add an API to DebugInfo

/CC @wasedaigo

Why is this needed?

In order to get hints to improve memory usages. Especially this matters in some special devices that have unified memory for CPU and GPU.

@hajimehoshi
Copy link
Owner Author

type DebugInfo struct {
    ...

    // TotalGPUImageMemoryUsageInBytes is the total image memory usage for GPU in bytes.
    // TotalGPUImageMemoryUsageInBytes is approximately the total memory usage for GPU.
    TotalGPUImageMemoryUsageInBytes int64
}

Do we need each image info?

@hajimehoshi
Copy link
Owner Author

#2207 is related.

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

No branches or pull requests

1 participant