Looking for Tips and Tricks to Improve Efficiency in Perspective (as well as making the views cleaner)

Hi everyone!

This post really looks for any idea or tips that could help me improve in perspective, not really actually solving our current problem.

We are currently working on a project that is enterily in perspective, we don't use vision.

Last week, one of my coworkers created a new View, and our memory cost went from 500MB to almost 3000MB. This was so bad that the gateway kept shutting down giving us this error.

INFO   | log    | 2025/01/20 18:18:00 | Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000540000000, 4294967296, 0) failed; error='The paging file is too small for this operation to complete' (DOS error/errno=1455)
INFO   | log    | 2025/01/20 18:18:00 | #
INFO   | log    | 2025/01/20 18:18:00 | # There is insufficient memory for the Java Runtime Environment to continue.
INFO   | log    | 2025/01/20 18:18:00 | # Native memory allocation (mmap) failed to map 4294967296 bytes for Failed to commit area from 0x0000000540000000 to 0x0000000640000000 of length 4294967296.

I have done some test and I came to the conclusion that it was the new View that when opened make everything crash.
Don't get me wrong, the view works when we allocated 16GB of memory, but with 8GB (what we were planning to use for now) doesn't.

I have made some views in Perspective so I'm familiar with it. However, I'm not really familiar with web behaviour.
What I'm looking is for tips on how to improve memory efficiency or memory leaks (really efficiency in general).

On the other part, we have a cosntant problem on loading times. Our views use some "Embedded Views" and sometimes when they are loading they show the default value written in params (I could give an example if neccesary). So you click, you see the default and maybe 1 or 2 seconds later the real data gets loaded and the view or the component changes.
What I am looking is for some way of making the loading faster or cleaner so you don't actually see things that doesn't correspond.

Sorry for the long text. I'm really looking for some way of starting and getting better so any idea or tips is appreciated.

Thank you!

Use Expression bindings instead of Script Transforms wherever possible, even if it means using runScript (as a last resort). They will execute quicker, and when I revamped a view that had lots of script transforms, I also noticed the memory use went way down (in the browser, anyway, not sure about the Gateway).

As far as the initial display of default param values, I generally try to make those defaults null/None, and use a COALESCE expression to display an empty string until a real value is available.

2 Likes

bmusson (Profile - bmusson - Inductive Automation Forum) helpfully pointed me to this free module for another issue I had yesterday:

Embr Periscope | Musson Industrial

One of the things it provides is an Embedded View+, which passes your parameters to the view on the server side instead of the client side, avoiding that anooying issue of loading/showing the defaults.

1 Like