Gfx: Potential leak on Metal backend related to acquiring command buffer.

Created on 22 Aug 2019  路  4Comments  路  Source: gfx-rs/gfx

  • GFX version:
    0.3.0 with PR
  • OS:
    macOS Mojave 10.14.6 (18G87)
  • GPU:
    Happens on both:
    NVIDIA GeForce GT 750M 2 GB
    Intel Iris Pro 1536 MB

I noticed a slow growing leak but couldn't reproduce it until I let the program run for 40 minutes straight with a couple of quads in the foreground. It grew for ~46mb to ~117mb but the one allocation I noticed the most was ~63mb. That being said Instruments does not indicate it as a leak so feel free to close it if it's not considered a leak.

The biggest one (~63mb) was under impl<B: Backend, C> CommandPool<B, C>

    /// Allocates a new primary command buffer from the pool.
    pub fn acquire_command_buffer<S: Shot>(&mut self) -> CommandBuffer<B, C, S> {
        let buffer = self.raw.allocate_one(RawLevel::Primary); // (`~63mb`)
        unsafe { CommandBuffer::new(buffer) }
    }

One level deeper.

fn allocate_one(&mut self, level: com::RawLevel) -> CommandBuffer {
        //TODO: fail with OOM if we allocate more actual command buffers
        // than our mega-queue supports.
        let inner = Arc::new(RefCell::new(CommandBufferInner {  //(`~63mb`)
            sink: None,
            level,
            backup_journal: None,
            #[cfg(feature = "dispatch")]
            backup_capacity: None,
            retained_buffers: Vec::new(),
            retained_textures: Vec::new(),
            active_visibility_queries: Vec::new(),
            events: Vec::new(),
            host_events: Vec::new(),
        }));
        self.allocated.push(Arc::clone(&inner)); //(~2.4mb) 

I got a large trace to share, but unable to upload at this time.

Metal request OSX bug medium

Most helpful comment

FWIW, I left my app (debug build) running all night, about 9 hours, and memory usage stayed around 108MB the entire time.

Using https://github.com/gfx-rs/wgpu-rs/commit/697393df4793e1a58578209885036114adfb9213

OS: macOS Mojave 10.14.6 (18G95)
GPU: Intel HD Graphics 630

(NOT TESTED this laptop also has a Radeon Pro 560)

All 4 comments

Did you try running the same program on other backends?

@nicbn No, unfortunately I can't for now.

FWIW, I left my app (debug build) running all night, about 9 hours, and memory usage stayed around 108MB the entire time.

Using https://github.com/gfx-rs/wgpu-rs/commit/697393df4793e1a58578209885036114adfb9213

OS: macOS Mojave 10.14.6 (18G95)
GPU: Intel HD Graphics 630

(NOT TESTED this laptop also has a Radeon Pro 560)

Yeah I can't replicate this either anymore.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kvark picture kvark  路  4Comments

clevijoki picture clevijoki  路  3Comments

Bastacyclop picture Bastacyclop  路  3Comments

kvark picture kvark  路  4Comments

kvark picture kvark  路  5Comments