Q: Server Side Logic's Parameter is by value or by reference?

As topic...


If I have huge BinaryData from Uploaded File:

- can I encapsulate logic and send BinaryData as parameter to another logic

- or should I processed it straight in 1 Logic Flow to minimize memory consumption?


Thanks.

Solution

Hi,


BinaryData is pass by reference, 

see also:

http://www.outsystems.com/help/servicestudio/9.1/index.htm#t=Designing_Actions%2FAbout_Input_Parameters.htm

cannot find the v10 equivalent quickly


Solution

Thanks for your information.

Input Parameters Passed as Reference

However, to avoid performance deterioration, when the action called is from the same module there are data types that are passed by reference:


    • Binary Data;

    • Object;

    • Lists.


Another question is how about custom Record type, is it passed by value or reference?

Thanks again.

Hi Harlin,

Records are always passed by value, but any lists inside the record are, afaik, passed by reference.

Thanks.

Okay, so that's an important information.


After a hour and a half trying to figure out what was going on, I finally got it.


I always knew lists and objects were passed by reference, but I did not realize it's only for actions inside the same module.


Whenever a list is passed to a referenced action (an action which belongs to a different module), the entire thing is copied over, so any changes made to that list inside the referenced action does not affect the original list!


Even extensions get the list by value and not by reference, except when we wrap the list in a ToObject function. So that's what I did: passed the list as object and made the desired changes through a .NET code.

Hi Caio,

In addition, when passing a Record List of type X to an Action that needs an input of List of type X (or vice versa), the conversion is silent, but of course here too it's effectively passed by value (or a copy is passed by reference, but the effect is the same).