Memory footprint considerations #1385
Replies: 8 comments 2 replies
-
Hi, what exactly you mean wit "grows very fast"? Does it stabilize at a certain point? Please provide more details and let it maybe also run for a day or such. |
Beta Was this translation helpful? Give feedback.
-
Yes sorry, Yes it is stable, it not seem to have a memory leak, is the cost to add a device to the server, I don't know if it's possible to reduce, just an observation. I used the humidity temperature example, but bridging devices is more noticable. |
Beta Was this translation helpful? Give feedback.
-
So yes I agree, and no we did not invested too much time into memory usage optimizations, also given that we are still not featurecomplete. I then did the onoff bridge with one device. 140MB initially ... then went down to 108MB
... was tested on a raspi 4 with nodejs 20 runnning |
Beta Was this translation helpful? Give feedback.
-
Assuming you're looking at RSS, it's kind of tricky to assess what impact the reported value will have on the system as it will include shared pages and pages the OS can reclaim if necessary (like @Apollon77's example demonstrates). For reference, I loaded a device on my PC with three endpoints (root, on/off light and window covering). Running an adhoc I loaded another device with two endpoints (root + on/off light). A heap snapshot there reports ~150KB less for code than for the 3 endpoint device but actually about 200KB more for strings. My takeaway from this in the past was that resource consumption for additional endpoints is fairly trivial... Enough so that they can get lost in the noise if you look at heap usage. What you might do is load up a bridge (or just an endpoint with synthetic devices) with the maximum # of devices you think you must realistically support... Ideally put some load on it too but even a static test is a good start. If the system becomes unresponsive or the heap usage gets higher than you think you can support let us know your requirements and we can look into some optimization strategies for you. |
Beta Was this translation helpful? Give feedback.
-
Thank you @Apollon77 and @lauckhart , I understand that this wasn't yet a focus for you, ok. This ticket was open to understand if optimization will be a focus to you or not, however I already open a ticket to the platform devs to expand this narrow limits where are more apps having this issue, so I hope they expand a little these limits. But thank you for you time, |
Beta Was this translation helpful? Give feedback.
-
In fact yes, sure we plan to also work on memory footprint, but in my eyes this only makes sense when we are a bit more feature complete. So it is on the list, but not "next-ish", but later. What you could try is - check the examples package ... there we show how it could be "bundled" into an executable ... would be interesting (and yes I did not tried this if it makes any difference and my idea is just dumb!) if this has an effect - in general "when bundling just the needed things" which also could make sure only the needed things are loaded ..... |
Beta Was this translation helpful? Give feedback.
-
I converted to a discussion... @rcaceiro 100mb is a reasonable target and you should be able to hit today I think. You need to tell node if there are memory limits in place. Otherwise it can be pretty lazy about garbage collection. You can do this with node's Also, ideally you would are constrained on unreclaimable memory rather than the somewhat arbitrary total rss size. To remain within the limit you or admins might want to consider running in a cgroup where you can set memory.high. This will cause the OS to reclaim memory so you don't have unnecessary pages hanging out. It can also force swap (for better or worse) if necessary & enabled. When I run a device in a cgroup limited to 100mb and have max old space set to 50mb, matter.js settles at ~34mb RssAnon and ~50mb RssFile. So total RSS is under your 100mb cap. I'm not an expert but I believe 34mb is the portion we will be able to improve with optimization. Anyway, thanks for bringing this up, researching was one of our TODOs. |
Beta Was this translation helpful? Give feedback.
-
I am using the new version 0.11.9 and I see improvements, I don't know if was your focus also, but thank you, nice job guys. |
Beta Was this translation helpful? Give feedback.
-
Hello,
I am developing a matter bridge, (non profit project) the device where this will run have some memory restrictions and I noticed that only the server consume 60MB of RAM and when we add more devices it grows very fast 2x with 3, 4 devices.
This topic is something that will be checked later or is something that is already very optimised and it is nothing more todo?
Thank you for this project amazing, anyway.
Beta Was this translation helpful? Give feedback.
All reactions