Announcement

Collapse
No announcement yet.

What are the best practices regarding javascript and memory?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • What are the best practices regarding javascript and memory?

    I have two scripts both accessing Oracle DBs. They work, but over time (weeks) they seem to fail. Restarting Mirth seems to correct the issue.

    In other languages there are best practices for house cleaning to prevent memory leaks. Are there any specific actions I should be taking in regards to variables and objects when I am done with them in Mirth/Javascript?

  • #2
    If they are java objects, you will want to perform any clean-up operations that you would do in java (such as closing any closeable objects.)

    For the most part, mirth doesn't hang on to object references created in user scripts for too long. Exceptions would be things placed in the global maps.

    If you have a variable containing a reference to a rather large object (maybe the entire contents of a file or something) you can set that variable to a different value (null or undefined if you are finished with the variable.) That will make the large object immediately eligible for garbage collection instead of waiting for the variable to go out of scope.

    Also, because of the way mirth runs filters and transformers in the same javascript context, any objects assigned to variables in the global context (rather than to variables declared with the var keyword) in the filter will carry through to the transformer of the same connector rather than falling out of scope when the filter finishes (this can also be used to your advantage if you want to pass values between the filter and transformer without having to store them in a mirth map.)
    Last edited by agermano; 12-17-2018, 01:24 PM.

    Comment

    Working...
    X