Dexie.js icon indicating copy to clipboard operation
Dexie.js copied to clipboard

dexie-observable keeps adding event listeners

Open MarMun opened this issue 3 years ago • 5 comments

Dexie-observable keeps adding event listeners (which are garbage collectible).

This is how it looks like (Chrome dev tools - performance monitor): DexieObservable

How to reproduce: import 'dexie-observable' // I remove this and event listener registration stops

I don't consider this critical (the listeners are GC'ed regularly).

However (nitpicking), the CPU usage (Chrome dev tools - performance monitor) of my app, while idle, is higher with it (0.9%- 1.5%) than without it (0% - 0.1%).

Also, I wanted to let you know...

Package versions:

dexie: 3.2.1
dexie-observable: 3.0.0-beta.11

MarMun avatar Feb 22 '22 12:02 MarMun

Thanks for sharing it and making me aware of it. The addon does actually work more as a base for dexie-syncable than a pure observation enabler and as such, it needs to do some heart beat communications for leader election when there are multiple tabs open - who will be the sync communicator. I suppose that could be a reason of what's going on in the backround. I will compare performance measuring between dexie-observable and dexie-cloud-addon at some point to see if the latter is more sparse on resources while idle.

dfahlander avatar Feb 22 '22 20:02 dfahlander

needs to do some heart beat communications for leader election when there are multiple tabs open

There is only one instance running (I think). No multiple tabs involved (in case that helps narrowing it down).

MarMun avatar Feb 23 '22 14:02 MarMun

The heart beat is always going on no matter if there are multiple tabs or not.

dfahlander avatar Feb 23 '22 14:02 dfahlander

After adding import 'dexie-observable'; Storage keeps rising.

  • Database empty.
  • Latest electron app.

Gist -> image image

leimantas avatar May 17 '22 12:05 leimantas

"dexie": "^3.2.2", "dexie-observable": "^3.0.0-beta.11"

After ~5min: image

leimantas avatar May 17 '22 12:05 leimantas