I have a working node that runs next to my application in Heroku that listens for specific paths in my Firebase database. The problem is that listening to these paths seems to take up a huge amount of memory. If I listen to changes in a path like the one below, it contains 13000 elements, if on my Heroku server it takes 147 mb of shared memory:
setInterval => @ref.log_memory('Listener interval') , 1000 @ref.firebaseClient.child('listings').on 'child_changed', (snap) => @ref.log('child_changed')
Output:
22:39:07 worker.1 | info: Memory: 35mb total - 66mb rss - 23mb heapUsed 22:39:08 worker.1 | info: Memory: 36mb total - 67mb rss - 18mb heapUsed 22:39:09 worker.1 | info: Memory: 37mb total - 69mb rss - 23mb heapUsed 22:39:10 worker.1 | info: Memory: 54mb total - 72mb rss - 25mb heapUsed 22:39:11 worker.1 | info: Memory: 54mb total - 82mb rss - 33mb heapUsed 22:39:13 worker.1 | info: Memory: 147mb total - 186mb rss - 94mb heapUsed 22:39:14 worker.1 | info: Memory: 147mb total - 186mb rss - 94mb heapUsed 22:39:15 worker.1 | info: Memory: 147mb total - 186mb rss - 94mb heapUsed 22:39:15 worker.1 | info: child_changed 22:39:16 worker.1 | info: Memory: 147mb total - 186mb rss - 95mb heapUsed 22:39:17 worker.1 | info: Memory: 147mb total - 186mb rss - 95mb heapUsed
If normal, does Firebase take up so much memory for the path it is listening to? Is it because it extracts all the elements in the path and listens to each element? Is there any way around this?
source share