web stats
Mirth Community - View Single Post - What are the best practices regarding javascript and memory?
View Single Post
Old 12-17-2018, 02:18 PM
agermano agermano is offline
Mirth Guru
Join Date: Apr 2017
Location: Indiana, USA
Posts: 1,110
agermano is on a distinguished road

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 at 02:24 PM.
Reply With Quote