Skip to content

toArray() causes memory leaks #625

@callumhay

Description

@callumhay

What is wrong?

Using toArray() appears to cause memory leaks for immutable textures (see below).

Where does it happen?

In GPU.js, running on my Windows 7 PC, headlessgl in node.js v12.18.1.

How do we replicate the issue?

Here is the code to reproduce on my system:

const pipelineFuncSettings = {
  output: [8, 8, 8],
  pipeline: true,
  returnType: 'Array(3)',
};

const clearFuncImmutable = gpu.createKernel(function(colour) {
  return [colour[0], colour[1], colour[2]];
}, {...this.pipelineFuncSettings, immutable: true, argumentTypes: {colour: 'Array(3)'}});

let framebufferTex =  clearFuncImmutable([0,0,0]);
while (true) {
  framebufferTex.delete();
  framebufferTex = clearFuncImmutable([0,0,0]);
  framebufferTex.toArray();
}

Let that run and watch the node.exe memory climb forever.
If you remove the toArray() line (i.e., framebufferTex.toArray();) then the program no longer appears to leak memory.

How important is this (1-5)?

  1. This shouldn't leak memory... or the documentation should explain clearly why this would leak memory and how to avoid it and get a CPU buffer from your textures/framebuffers without worrying about it.

Expected behavior (i.e. solution)

This shouldn't leak memory, I should be able to loop forever - grabbing a CPU array of my framebuffer texture each time - in a stable state.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions