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

Memory leak when multiInstance set to true #778

Closed
erguotou520 opened this Issue Aug 30, 2018 · 8 comments

Comments

Projects
None yet
2 participants
@erguotou520
Copy link

commented Aug 30, 2018

Case

It got memery leak when multiInstance set to true.

Issue

I just create a RxDB instance with multiInstance to be true in the Electron page.
And do nothing but just record the Performance in devtool.
Here is the memery usage:

image

It seems the the problem code is in src/socket.js's pull loop function.

Info

Code

  const db = await RxDB.create({
    name: 'test',
    adapter: 'idb',
    multiInstance: true
  })
  await db.collection({
    name: 'heroes',
    schema
  })
  console.log(db)

And the schema is:

export default {
  'title': 'hero schema',
  'version': 0,
  'description': 'describes a simple hero',
  'type': 'object',
  'properties': {
    'name': {
      'type': 'string',
      'primary': true
    },
    'color': {
      'type': 'string'
    },
    'healthpoints': {
      'type': 'number',
      'min': 0,
      'max': 100
    },
    'secret': {
      'type': 'string'
    },
    'birthyear': {
      'type': 'number',
      'final': true,
      'min': 1900,
      'max': 2050
    },
    'skills': {
      'type': 'array',
      'maxItems': 5,
      'uniqueItems': true,
      'item': {
        'type': 'object',
        'properties': {
          'name': {
            'type': 'string'
          },
          'damage': {
            'type': 'number'
          }
        }
      }
    }
  },
  'required': ['color']
}
@erguotou520

This comment has been minimized.

Copy link
Author

commented Aug 30, 2018

The memery can't be released until click the Collect garbage button.

@pubkey

This comment has been minimized.

Copy link
Owner

commented Aug 30, 2018

@erguotou520 this type of memory-leak was reported before, but noone send a reproducible test.

The whole multiInstance-handling was rewritten for version 8.0.0 to not use the hacky socket-workarround see here.

I do not think it's worth the time to fix this, because the next major-release will come soon.
However a PR with a fix for this is welcomed if you need a quick solution.

@erguotou520

This comment has been minimized.

Copy link
Author

commented Aug 30, 2018

When will 8.0.0 be stable release?

@pubkey

This comment has been minimized.

Copy link
Owner

commented Aug 30, 2018

I do not know. I planned to release the beta on the weekend. If there are no big issues it will take another week to release the stable version.

@erguotou520

This comment has been minimized.

Copy link
Author

commented Aug 31, 2018

I think the workaround is expose gc function to the global and call global.gc && global.gc() in pull function?

@pubkey

This comment has been minimized.

Copy link
Owner

commented Sep 5, 2018

@erguotou520 have you checked if this problem appears also in the 8.0.0-beta?

@erguotou520

This comment has been minimized.

Copy link
Author

commented Sep 6, 2018

Not successfully migrate to 8.0.0 😞

@pubkey pubkey changed the title Memery leak when multiInstance set to true Memory leak when multiInstance set to true Sep 10, 2018

@pubkey

This comment has been minimized.

Copy link
Owner

commented Sep 18, 2018

I just released 8.0.0 which should fix this. Reopen if not.

@pubkey pubkey closed this Sep 18, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.