Skip to content

Memory leak calling native methods #2575

@tommoor

Description

@tommoor

For us this shows up with the getCursorScreenPoint method as we poll it to find when the users mouse position is at the edge of the screen. However every time the method is called it leaks a non-insignificant amount of memory.

I've put together a demo here: https://github.com/speak/electron-bug-demos/tree/get-cursor-screen-point-memory-leak - simply run the app and watch the memory usage shoot up. This is what the usage in timeline looks like:

image

The core code is simply:

this.interval = setInterval(function(){
  var screen = require('screen');
  var point = screen.getCursorScreenPoint();
  console.log(point.x, point.y);
}, 10);

Hopefully someone can point out something stupid I'm doing - I'd prefer that to this being a real bug 😉

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